示例#1
0
        public void AddRpcHandlers <T>(ICoolRpc rpcHandler) where T : ICoolRpc
        {
            rpcHandler.Init(new Serializer(), this, 0);

            int id = RpcServiceHelper.GetID <T>();

            Contract.Ensures(rpcHandler != null && m_aRpcHandlerMaps[id] == null);

            IRPCHandlerMap handlerMap = RpcServiceHelper.CreateRpcHandlerMap <T>(rpcHandler);

            m_aRpcHandlerMaps[id] = handlerMap;
        }
示例#2
0
        public T GetRpc <T>() where T : ICoolRpc
        {
            ICoolRpc rpc = m_aCoolRpcs[RpcServiceHelper.GetID <T>()];

            if (rpc == null)
            {
                rpc = RpcServiceHelper.CreateRpc <T>();
                rpc.Init(new Serializer(), this, 0);

                m_aCoolRpcs[RpcServiceHelper.GetID <T>()] = rpc;
            }

            return((T)rpc);
        }