Documentation ¶
Index ¶
- Constants
- func Logger(message string) (err error)
- type Client
- func (c *Client) AdvanceTram() error
- func (c *Client) AsyncAdvance()
- func (c *Client) GetNextStop() (nextStop int, err error)
- func (c *Client) Init(serverIP string) (err error)
- func (c *Client) RegisterRoute(routeID int) error
- func (c *Client) SetCurrentLocation(currentStop int, previousStop int) error
- func (c *Client) UpdateTramLocation(nextStop int) (err error)
- type Message
- type MessageType
- type RPCMessage
- type Record
- type Server
- func (t *Server) CallBroker(in *RPCMessage, out *RPCMessage) error
- func (t *Server) GetNextStop(in *RPCMessage, out *RPCMessage) error
- func (t *Server) RegisterTram(in *RPCMessage, out *RPCMessage) error
- func (t *Server) UnregisterTram(in *RPCMessage, out *RPCMessage) error
- func (t *Server) UpdateTramLocation(in *RPCMessage, out *RPCMessage) error
- type Tram
Constants ¶
const ( MAX_ROUTE_TRAM int = 5 MIN_ROUTE_STOPS int = 5 )
define system limits
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { TramObj *Tram // contains filtered or unexported fields }
Client represents the functional Client and includes the open socket, requests count and new Tram object for passing to server.
func (*Client) AdvanceTram ¶
AdvanceTram moves the current tram to the next stop
func (*Client) GetNextStop ¶
GetNextStop requests the next stop ID for the current route the tram/client is on. It is directional therefore previous stop and current stop IDs are passed as params.
func (*Client) Init ¶
Init initialises Client functionality by establishing connection to server and generating a new tram object.
func (*Client) RegisterRoute ¶
RegisterRoute enables tram to be bound to a specific route this is a prerequisite for issuing any further commands to the server.
func (*Client) SetCurrentLocation ¶
SetCurrentLocation overwrites current stops in local Tram object
func (*Client) UpdateTramLocation ¶
UpdateTramLocation notifies the server that the tram has arrived at the next tram stop.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Custom message encoding struct
func (*Message) Unmarshall ¶
func (message *Message) Unmarshall() *RPCMessage
Unmarshall decodes CsvData from the Message. should return new RPCMessage with parsed values.
type RPCMessage ¶
type RPCMessage struct { MessageType MessageType TranslationId uint32 RPCId *uuid.UUID RequestID uint32 ProcedureID uint32 CsvData string Status uint32 }
func (*RPCMessage) Marshall ¶
func (message *RPCMessage) Marshall() *Message
encode CsvData should return *Message
func (*RPCMessage) PrepReply ¶
func (m *RPCMessage) PrepReply(in *RPCMessage)
type Server ¶
Main server structure
func (*Server) CallBroker ¶
func (t *Server) CallBroker(in *RPCMessage, out *RPCMessage) error
CallBroker routes calls to various functions this is not really necessary as I am exposing selected methods through RPC registry of Server struct but... for the sake of assignment here it is.
func (*Server) GetNextStop ¶
func (t *Server) GetNextStop(in *RPCMessage, out *RPCMessage) error
GetNextStop functionality is directional
func (*Server) RegisterTram ¶
func (t *Server) RegisterTram(in *RPCMessage, out *RPCMessage) error
RegisterTram functionality enables trams to be attached to specific routes.
func (*Server) UnregisterTram ¶
func (t *Server) UnregisterTram(in *RPCMessage, out *RPCMessage) error
UnregisterTram removes tramID from current Clients list and the route register
func (*Server) UpdateTramLocation ¶
func (t *Server) UpdateTramLocation(in *RPCMessage, out *RPCMessage) error
UpdateTramLocation function returns empty CSV if OK, otherwise -1