/// <summary> /// Регистрация клиента /// </summary> /// <param name="msg"></param> /// <returns></returns> public Msg RegisterClient(Msg msg) { Console.WriteLine($"RegisterClient: {msg.ClientName}"); Msg result = new Msg() { ClientName = msg.ClientName, GUID = msg.GUID }; lock (locker) { result = new Msg() { ClientName = msg.ClientName, GUID = msg.GUID }; if (!String.IsNullOrEmpty(msg.ClientName)) { IBroadcastorCallBack callBack = OperationContext.Current.GetCallbackChannel <IBroadcastorCallBack>(); if (clients.Keys.Contains(msg.ClientName)) { clients.Remove(msg.ClientName); } clients.Add(msg.ClientName, callBack); result.MsgStatus = MSGSTATUS.SUCCESS; } } return(result); }
public void GetInService(string id) { OperationContext.Current.Channel.Closed += new EventHandler(Channel_Closed); OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted); IBroadcastorCallBack callback = OperationContext.Current.GetCallbackChannel <IBroadcastorCallBack>(); if (!clients.Keys.Contains(id)) { clients.Add(id, callback); } }
public void RegisterClient(int clientId) { if (clientId > 0) { IBroadcastorCallBack callback = OperationContext.Current?.GetCallbackChannel <IBroadcastorCallBack>(); if (_clients.Keys.Contains(clientId)) { _clients.Remove(clientId); ObjFactory.Instance.CreateLogger() .Log("UnRegistered Client = " + clientId, GetType().Name, false); } _clients.Add(clientId, callback); ObjFactory.Instance.CreateLogger() .Log("Registered Client = " + clientId, GetType().Name, false); ObjFactory.Instance.CreateOrder().UpdateMarketOrderBook(clientId); } }
public void RegisterClient(string clientName) { if (clientName != null && clientName != "") { try { IBroadcastorCallBack callback = OperationContext.Current.GetCallbackChannel <IBroadcastorCallBack>(); lock (locker) { //remove the old client if (clients.Keys.Contains(clientName)) { clients.Remove(clientName); } clients.Add(clientName, callback); } } catch (Exception ex) { } } }