Socket

Socket Server

The Socket Server functions as listed:

  • Start socket server function is used to start the socket server.
  • When the socket is connected, it first checks authenticity using JSON webtoken.
  • This JWT access token is provided with the query parameter during the HandShake process between socket-server and socket-client.
  • JWT access token is the same as that of token which is provided to the user at the time of login.
  • If the socket is authenticated, then the sokcet is added to the socket store using addByuserId(), else the socket is disconnected.

Socket Handler

Socket handler contains functionality which helps to manage different scenarios related to socket. Each scenario is taken as a story, which is handled separately. Socket handler manages three stories, namely: request trip, start trip and update location.

Request Trip

Request trip handler, handles many other trip request scenario.

  • When the rider make a request for a trip, this emits a socket event from the rider side which is handled by requstTripHandler()
  • Each request trip is in the mongoDB order collection.
  • Takes in the map coordinates of a restaurant.
  • The coordinates are updated in database Based on the coordinates a query is run which fetches nearby drivers in that region.

  • During the trip request, the order request Status can have following values:

    • Processing: When order is placed
    • Accept: When driver accept the order.
    • Picked: When driver picked order from restaurant.
    • Arrived When driver arrived at delivery location

    requestDriverResponse

    When driver accept or reject order. if accept then update driver Id and order status to Order collection

    UpdateOrderStatusAtUser

    when driver accept the request.

    responseTimedOut

    when driver reject the order request.

UpdateLocation Handler

  • Update location handler handles updation of the GPS location of the driver.

  • It will update the gps location at user side or driver side

  • UpdateOrderStatus:

    It will update the order status at driver side

results matching ""

    No results matching ""