//--------------------------------------------------------------------- protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters) { _eRpcCmd op_code = (_eRpcCmd)operationRequest.OperationCode; if (_eRpcCmd.SyncPeerInfo == op_code) { mRemoteNodeType = (byte)operationRequest.Parameters[0]; if (mListener != null) { mListener.onSessionConnect(mEntityMgr.NodeType, mRemoteNodeType, mRpcSession); } } else if (mRpcSession != null) { Dictionary <byte, object> p = operationRequest.Parameters; _tEntityRpcData data; data.rpc_id = (long)p[0]; data.from_node = (byte)p[1]; data.method_id = (short)p[2]; data.map_param = (Dictionary <byte, object>)p[3]; data.session_recv = null; mRpcSession.recvRpcData(ref data); } }
//--------------------------------------------------------------------- public void update() { Service(); lock (mQueSessionEventLock) { if (mQueSessionEvent.Count == 0) { return; } SessionEvent se = mQueSessionEvent.Dequeue(); if (mListener == null) { return; } if (se.connect) { mListener.onSessionConnect(se.node_type_local, se.node_type_remote, se.session); } else { mListener.onSessionDisconnect(se.node_type_local, se.node_type_remote, se.session); } } }
//--------------------------------------------------------------------- public PhotonServerPeerC(IRpcProtocol protocol, IPhotonPeer unmanaged_peer, EntityMgr entity_mgr, byte remote_node_type, RpcSessionListener listener) : base(protocol, unmanaged_peer) { mEntityMgr = entity_mgr; mRpcSession = new RpcSession(mEntityMgr, this); mListener = listener; mRemoteNodeType = remote_node_type; Dictionary <byte, object> map_param = new Dictionary <byte, object>(); map_param[0] = mEntityMgr.NodeType; map_param[1] = 0;// local_node_id OperationRequest operation_request = new OperationRequest((byte)_eRpcCmd.SyncPeerInfo, map_param); SendResult r = SendOperationRequest(operation_request, new SendParameters { ChannelId = 0 }); if (r != SendResult.Ok) { EbLog.Error("PhotonServerPeerC SyncPeerInfo Result=" + r); } if (mListener != null) { mListener.onSessionConnect(mEntityMgr.NodeType, mRemoteNodeType, mRpcSession); } }