Permalink
Browse files

added CliendID cookie to rpc ServerHandshake. client sends that clien…

…t ID along with its RPC calls for identification
  • Loading branch information...
1 parent d4b4461 commit eed6d9c6f8ce26c0e4c180f08880cd1ed87b7136 @skelterjohn skelterjohn committed Sep 28, 2012
Showing with 7 additions and 0 deletions.
  1. +2 −0 client/client.go
  2. +1 −0 client/serviceclient.go
  3. +2 −0 handshake.go
  4. +1 −0 messages.go
  5. +1 −0 service/service.go
View
@@ -19,6 +19,7 @@ var (
type ServiceResource struct {
rpcClient *rpc.Client
service *skynet.ServiceInfo
+ clientID string
closed bool
}
@@ -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
View
@@ -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)
View
@@ -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.
View
@@ -20,6 +20,7 @@ type StopResponse struct {
}
type ServiceRPCIn struct {
+ ClientID string
Method string
RequestInfo *RequestInfo
In []byte
View
@@ -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)

0 comments on commit eed6d9c

Please sign in to comment.