示例#1
0
        /// <summary>
        /// 执行接收的外部消息
        /// </summary>
        /// <param name="service"></param>
        /// <param name="currentServiceType">当前上下文的类型</param>
        /// <param name="messageModel">消息模型</param>
        /// <returns></returns>
        private async Task EexecReciveMessage(object service, Type currentServiceType, WebSocketMessageModel messageModel)
        {
            //获取方法
            var methodCacheInfo = MethodCache.Get(currentServiceType, messageModel.action);
            //获取方法的参数
            var parameters = methodCacheInfo.ParameterInfos;

            //是否含有参数
            var isParamater = parameters.Count() > 0;
            //参数信息
            var parameterEntity = parameters.Count() > 0 ?await messageModel.message?.ToString().ToDeserializeAsync(parameters[0].ParameterType) : null;

            //执行操作
            await NarutoWebSocketServiceExpression.ExecAsync(service, messageModel.action, isParamter : isParamater, parameterEntity : parameterEntity, parameterType : isParamater?parameters[0].ParameterType : default).ConfigureAwait(false);
        }
示例#2
0
 /// <summary>
 /// 执行内部消息
 /// </summary>
 /// <param name="service"></param>
 /// <param name="webSocketClient"></param>
 /// <param name="reciveMessageBase"></param>
 /// <returns></returns>
 private async Task EexecInternalMessage(object service, WebSocketClient webSocketClient, MessageBase reciveMessageBase)
 {
     //执行操作
     await NarutoWebSocketServiceExpression.ExecAsync(service, reciveMessageBase.action, isParamter : true, parameterEntity : webSocketClient, webSocketClient.GetType()).ConfigureAwait(false);
 }