Skip to content

Commit

Permalink
added CliendID cookie to rpc ServerHandshake. client sends that clien…
Browse files Browse the repository at this point in the history
…t ID along with its RPC calls for identification
  • Loading branch information
skelterjohn committed Sep 28, 2012
1 parent d4b4461 commit eed6d9c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
type ServiceResource struct {
rpcClient *rpc.Client
service *skynet.ServiceInfo
clientID string
closed bool
}

Expand Down Expand Up @@ -162,6 +163,7 @@ func getConnectionFactory(s *skynet.ServiceInfo) (factory pools.Factory) {
resource := ServiceResource{
rpcClient: bsonrpc.NewClient(conn),
service: s,
clientID: sh.ClientID,
}

return resource, nil
Expand Down
1 change: 1 addition & 0 deletions client/serviceclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func (c *ServiceClient) sendToInstance(sr ServiceResource, requestInfo *skynet.R
sin := skynet.ServiceRPCIn{
RequestInfo: requestInfo,
Method: funcName,
ClientID: sr.clientID,
}

sin.In, err = bson.Marshal(in)
Expand Down
2 changes: 2 additions & 0 deletions handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type ServiceHandshake struct {
// Registered indicates the state of this service. If it is false, the connection will
// close immediately and the client should look elsewhere for this service.
Registered bool
// ClientID is a UUID that is used by the client to identify itself in RPC requests.
ClientID string
}

// ClientHandshake is sent by the client to the service after receipt of the ServiceHandshake.
Expand Down
1 change: 1 addition & 0 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type StopResponse struct {
}

type ServiceRPCIn struct {
ClientID string
Method string
RequestInfo *RequestInfo
In []byte
Expand Down
1 change: 1 addition & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ loop:
// send the server handshake
sh := skynet.ServiceHandshake{
Registered: s.Registered,
ClientID: skynet.UUID(),
}
encoder := bsonrpc.NewEncoder(conn)
err := encoder.Encode(sh)
Expand Down

0 comments on commit eed6d9c

Please sign in to comment.