Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…t ID along with its RPC calls for identification
  • Loading branch information...
commit eed6d9c6f8ce26c0e4c180f08880cd1ed87b7136 1 parent d4b4461
@skelterjohn skelterjohn authored
View
2  client/client.go
@@ -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
1  client/serviceclient.go
@@ -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
2  handshake.go
@@ -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
1  messages.go
@@ -20,6 +20,7 @@ type StopResponse struct {
}
type ServiceRPCIn struct {
+ ClientID string
Method string
RequestInfo *RequestInfo
In []byte
View
1  service/service.go
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.