示例#1
0
        public void RegisterRemotePlugin(string ServerIdentify, string[] plugin)
        {
            //客户端回调
            IDataReply callback = OperationContext.Current.GetCallbackChannel <IDataReply>();

            RemotePluginManage.RegisterRemotePlugin(callback, ServerIdentify, plugin);
        }
示例#2
0
        //路径执行到下一个节点
        private static string PathNextRequest(string plugin, string controller, string method, string jsondata, HeaderParameter para)
        {
            string retJson = null;

            try
            {
                para.NodePath.NextStep();     //节点路径下一步
                if (para.NodePath.IsEndMNode) //到达终节点
                {
                    //执行本地数据请求
                    retJson = LocalDataRequest(plugin, controller, method, jsondata, para);
                }
                else if (para.NodePath.nextMNodeDirection == "<up>")//向上
                {
                    ClientLink clientlink = SuperClient.CreateDataClient();
                    using (var scope = new OperationContextScope(clientlink.ClientObj.WcfService.InnerDuplexChannel as IContextChannel))
                    {
                        HeaderOperater.AddMessageHeader(OperationContext.Current.OutgoingMessageHeaders, para);
                        retJson = clientlink.ClientObj.WcfService.ProcessRequest(clientlink.ClientObj.ClientID, plugin, controller, method, jsondata);
                    }
                }
                else if (para.NodePath.nextMNodeDirection == "<down>")//向下
                {
                    IDataReply dataReply = SuperClient.CreateDataReply(para.NodePath.nextMNode);
                    retJson = dataReply.ReplyProcessRequest(para, plugin, controller, method, jsondata);
                }

                return(retJson);
            }
            catch (Exception err)
            {
                throw err;
            }
        }
示例#3
0
        //string ns = "http://www.efwplus.cn/";
        public string CreateClient(string clientName)
        {
            //客户端回调
            IDataReply      mCallBack = OperationContext.Current.GetCallbackChannel <IDataReply>();
            HeaderParameter para      = HeaderOperater.GetHeaderValue(OperationContext.Current.RequestContext.RequestMessage);
            string          ClientID  = ClientManage.CreateClient(clientName, DateTime.Now, mCallBack, para.pluginname, para.replyidentify);

            return(ClientID);
        }
示例#4
0
        //在订阅中调用
        public static void RegisterRemotePlugin(IDataReply callback, string ServerIdentify, string[] plugin)
        {
            //RemotePluginDic = new List<RemotePlugin>();

            //自己没必要注册自己
            if (ServerIdentify == WcfGlobal.Identify)
            {
                return;
            }
            bool         isChanged = false;
            RemotePlugin rp        = null;

            if (RemotePluginDic.FindIndex(x => x.ServerIdentify == ServerIdentify) > -1)
            {
                rp = RemotePluginDic.Find(x => x.ServerIdentify == ServerIdentify);
                //rp.clientService = callback;

                List <string> newplugin = rp.plugin.ToList();
                foreach (var p in plugin)
                {
                    //新注册的插件在原来插件中找不到,则新增
                    if (newplugin.ToList().FindIndex(x => x == p) == -1)
                    {
                        newplugin.Add(p);
                        isChanged = true;
                    }
                }
                foreach (var p in newplugin)
                {
                    //如果注册的插件在新注册插件中找不到,则移除
                    if (plugin.ToList().FindIndex(x => x == p) == -1)
                    {
                        newplugin.Remove(p);
                        isChanged = true;
                    }
                }
                rp.plugin = newplugin.ToArray();
            }
            else
            {
                rp = new RemotePlugin();
                rp.ServerIdentify = ServerIdentify;
                rp.callback       = callback;
                rp.plugin         = plugin;
                RemotePluginDic.Add(rp);
                isChanged = true;
            }

            if (isChanged == true)
            {
                //重新注册远程插件
                //?
            }
        }
示例#5
0
        public static string CreateClient(string clientName, DateTime time, IDataReply dataReply, string plugin, string replyidentify)
        {
            string clientId = Guid.NewGuid().ToString();

            try
            {
                AddClient(clientId, clientName, time, dataReply, plugin, replyidentify);
                return(clientId);
            }
            catch (Exception ex)
            {
                throw new System.ServiceModel.FaultException(ex.Source + ":创建客户端运行环境失败!");
            }
        }
示例#6
0
        public void Subscribe(string ServerIdentify, string clientId, string publishServiceName)
        {
            IDataReply callback = OperationContext.Current.GetCallbackChannel <IDataReply>();

            PublishServiceManage.Subscribe(ServerIdentify, clientId, publishServiceName, callback);
        }
示例#7
0
        //public static HostWCFMsgHandler hostwcfMsg;
        private static void AddClient(string clientId, string clientName, DateTime time, IDataReply dataReply, string plugin, string replyidentify)
        {
            lock (syncObj)
            {
                ClientInfo info = new ClientInfo();
                info.clientId       = clientId;
                info.clientName     = clientName;
                info.startTime      = time;
                info.dataReply      = dataReply;
                info.IsConnect      = true;
                info.plugin         = plugin;
                info.ServerIdentify = replyidentify;

                ClientDic.Add(clientId, info);
            }
            ShowMsg(Color.Blue, DateTime.Now, "客户端[" + clientName + "]已连接WCF服务主机");
        }
示例#8
0
 /// <summary>
 /// 客户端订阅
 /// </summary>
 /// <param name="ServerIdentify"></param>
 /// <param name="clientId"></param>
 /// <param name="publishServiceName"></param>
 /// <param name="callback"></param>
 public static void Subscribe(string ServerIdentify, string clientId, string publishServiceName, IDataReply callback)
 {
     if (ServerIdentify == WcfGlobal.Identify)
     {
         return;                                      //不能订阅自己
     }
     if (subscriberList.FindIndex(x => x.clientId == clientId && x.publishServiceName == publishServiceName) == -1)
     {
         Subscriber sub;
         lock (syncObj)
         {
             sub                    = new Subscriber();
             sub.clientId           = clientId;
             sub.publishServiceName = publishServiceName;
             sub.callback           = callback;
             sub.ServerIdentify     = ServerIdentify;
             subscriberList.Add(sub);
         }
         ShowHostMsg(Color.Blue, DateTime.Now, "客户端[" + clientId + "]订阅“" + publishServiceName + "”服务成功!");
         //SendNotify(sub);
     }
 }
示例#9
0
        /// <summary>
        /// 客户端订阅
        /// </summary>
        /// <param name="ServerIdentify"></param>
        /// <param name="clientId"></param>
        /// <param name="publishServiceName"></param>
        /// <param name="callback"></param>
        public static void Subscribe(string ServerIdentify, string publishServiceName, IDataReply callback)
        {
            if (ServerIdentify == WcfGlobal.Identify)
            {
                return;                                      //不能订阅自己
            }
            UnSubscribe(ServerIdentify, publishServiceName); //先卸载掉
            //然后重新订阅
            Subscriber sub;

            lock (syncObj)
            {
                sub = new Subscriber();
                sub.publishServiceName = publishServiceName;
                sub.callback           = callback;
                sub.ServerIdentify     = ServerIdentify;
                subscriberList.Add(sub);
            }
            ShowHostMsg(Color.Blue, DateTime.Now, "订阅者[" + ServerIdentify + "]订阅“" + publishServiceName + "”服务成功!");
            SendNotify(sub);
        }