示例#1
0
        /// <summary>
        /// 发送内部通信
        /// </summary>
        /// <param name="Param"></param>
        /// <param name="Session"></param>
        public static void SendInternalInfo(SocketSerializeData SerializeData, ISocketSession Session = null)
        {
            ISocketResult Param = new SocketResultDefault()
            {
                Router = SerializeData.Route, SocketJsonData = SerializeData.Providor?.ToJson()
            };

            SocketClient.Send(SocketMiddleData.Middle(SendTypeEnum.InternalInfo, Param, Session, SocketConstConfig.ClientPort).ToJson());
        }
示例#2
0
        /// <summary>
        /// 转化结果
        /// </summary>
        /// <param name="Param"></param>
        /// <returns></returns>
        public SocketMiddleData ExecuteMapper(object Param)
        {
            JObject        Obj      = (Param as string).ToModel <JObject>();
            SendTypeEnum   SendType = Enum.Parse <SendTypeEnum>(Obj["SendType"].ToString());
            int?           SendPort = Convert.ToInt32(Obj["SendPort"].ToString());
            ISocketResult  Result   = Obj["MiddleResult"].ToJson().ToModel <SocketResultDefault>();
            ISocketSession Session  = Obj["Session"].ToJson().ToModel <SocketSessionDefault>();

            return(SocketMiddleData.Middle(SendType, Result, Session, SendPort));
        }
示例#3
0
        /// <summary>
        /// 查询需要生成APIJson的接口
        /// </summary>
        public SocketMiddleData FindLibrary()
        {
            List <Type> SourceType = DependencyLibrary.Dependency.Where(item => item.GetCustomAttribute(typeof(SocketRouteAttribute)) != null).ToList();

            foreach (var Items in SourceType)
            {
                List <string>        Route       = new List <string>();
                SocketRouteAttribute SocketRoute = (Items.GetCustomAttribute(typeof(SocketRouteAttribute)) as SocketRouteAttribute);
                string ControllerName            = string.Empty;
                if (SocketRoute.ControllerName.IsNullOrEmpty())
                {
                    ControllerName = Items.Name;
                }
                else
                {
                    ControllerName = SocketRoute.ControllerName;
                }
                Items.GetMethods().Where(x => x.GetCustomAttribute(typeof(SocketMethodAttribute)) != null).ToList().ForEach(Item =>
                {
                    SocketMethodAttribute SocketMethod = (Item.GetCustomAttribute(typeof(SocketMethodAttribute)) as SocketMethodAttribute);
                    string SocketUrl = string.Empty;
                    if (SocketMethod.MethodName.IsNullOrEmpty())
                    {
                        SocketUrl = $"{SocketRoute.InternalServer}/{ControllerName}/{Item.Name}";
                    }
                    else
                    {
                        SocketUrl = $"{SocketRoute.InternalServer}/{ControllerName}/{SocketMethod.MethodName}";
                    }
                    if (!SocketMethod.MethodVersion.IsNullOrEmpty())
                    {
                        SocketUrl = SocketUrl + "/" + SocketMethod.MethodVersion;
                    }
                    Route.Add(SocketUrl.ToLower());
                });
                XPlusEx.XTry(() =>
                {
                    var Key = SocketRoute.InternalServer.ToLower();
                    if (SocketJson.ContainsKey(Key))
                    {
                        SocketJson[Key].AddRange(Route);
                    }
                    else
                    {
                        SocketJson.Add(Key, Route);
                    }
                }, Ex => throw Ex);
            }
            CreateSocketApiJsonScript();
            return(SocketMiddleData.Middle(SendTypeEnum.Init, SocketResultDefault.SetValue(null, SocketJson.ToJson())));
        }
示例#4
0
 /// <summary>
 /// 回调数据
 /// </summary>
 /// <param name="Param"></param>
 /// <param name="SendPort"></param>
 private static void CallBackInternalInfo(ISocketResult Param, int?SendPort)
 {
     SocketClient.Send(SocketMiddleData.Middle(SendTypeEnum.CallBack, Param, null, SendPort).ToJson());
 }