public void ConsoleLeave(string console) { // Unsubscribe the user from the conversation. //if station is in the dictionary list (to avoid calling consoleLeave twice) if (_ConnectedConsoleDict.ContainsKey(console)) { IMessageServiceCallback connectedConsole = _ConnectedConsoleDict[console]; //if (_ConsoleCallbackList.Contains(connectedConsole)) //{ //_ConsoleCallbackList.Remove(connectedConsole); _ConnectedConsoleDict.Remove(console); _ConnectedConsoleList.Remove(console); _ConnectedConsoleNo--; //Update the station status foreach (StationStatus station in StationIDList) { if (station.Station.Equals(console)) { station.Status = "Offline"; } } //} _GatewayCallbackList.ForEach( delegate(IMessageServiceCallback gatewaycallback) { gatewaycallback.EditConnStatus(console, "Offline"); }); } }
//Sub to server to receive msg from server public void ConsoleJoin(string console) { // Add the connected console channel into the list IMessageServiceCallback connectedConsole = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); //Overwrite if (_ConnectedConsoleDict.ContainsKey(console)) { _ConnectedConsoleList.Remove(console); _ConnectedConsoleDict.Remove(console);//Bind the username to the callback channel ID _ConnectedConsoleNo--; } _ConnectedConsoleList.Add(console); _ConnectedConsoleDict.Add(console, connectedConsole);//Bind the username to the callback channel ID _ConnectedConsoleNo++; //Update the station status (for case if mutiple gateway existed) foreach (StationStatus station in StationIDList) { if (station.Station.Equals(console)) { station.Status = "Online"; } } //Handle case where 2 client log in as same ID _GatewayCallbackList.ForEach( delegate(IMessageServiceCallback gatewaycallback) { gatewaycallback.EditConnStatus(console, "Online"); }); }
public void SendMessage(Message message) { InsertMessage(message); IMessageServiceCallback receiverCallBack = _clients?.First(client => client.Key == message.ReceiverId).Value; receiverCallBack?.ForwardToClient(message); }
public void RemovefromMsgQueue(string station, string CodingID) { if (_ConnectedConsoleList.Contains(station)) { IMessageServiceCallback tmpCallback = _ConnectedConsoleDict[station]; tmpCallback.UpdateRemoveMsgList(CodingID); } }
public void RegisterClient(string guid) { srsvc.Log.Info("Registering: {0}", guid); IMessageServiceCallback registeredUser = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); ClientPipes.callbackList.AddOrUpdate(guid, registeredUser, (i, v) => registeredUser); }
public void GatewayLeave() { //Unsubscribe the user to the conversation IMessageServiceCallback connectedGateway = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); if (_GatewayCallbackList.Contains(connectedGateway)) { _GatewayCallbackList.Remove(connectedGateway);//Note the callback list is just a list of channels. } }
/* * CAD join and leave in order to place a channel path here */ public void CADJoin() { // Subscribe the user to the conversation IMessageServiceCallback connectedCAD = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); if (!_CADCallbackList.Contains(connectedCAD)) { _CADCallbackList.Add(connectedCAD);//Note the callback list is just a list of channels. } }
public void Connect(User user) { _callBack = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); if (_callBack != null) { _clients.Add(user.UserId, _callBack); _users.Add(user); _clients?.ToList().ForEach(c => c.Value.UserConnected(_users)); System.Console.WriteLine($"{ user.Name} Just Connected"); } }
public void Connect(User user) { _callback = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); if (_callback != null) { _clients.Add(user.UserId, _callback); _activeUsers.Add(user); _clients?.ToList().ForEach(client => client.Value.UsersConnected(_activeUsers)); } }
public int LeaveTheConversation(string userName) { // Unsubscribe the user from the conversation. IMessageServiceCallback registeredUser = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); if (_callbackList.Contains(registeredUser)) { _callbackList.Remove(registeredUser); _registeredUsers--; } // Notify everyone that user has arrived. // Use an anonymous delegate and generics to do our dirty work. _callbackList.ForEach( delegate(IMessageServiceCallback callback) { callback.NotifyUserLeftTheConversation(userName); }); return(_registeredUsers); }
public int JoinTheConversation(string userName) { // Subscribe the user to the conversation IMessageServiceCallback registeredUser = OperationContext.Current.GetCallbackChannel <IMessageServiceCallback>(); if (!_callbackList.Contains(registeredUser)) { _callbackList.Add(registeredUser); } _callbackList.ForEach( delegate(IMessageServiceCallback callback) { callback.NotifyUserJoinedTheConversation(userName); _registeredUsers++; }); return(_registeredUsers); }
public void TargetMsg(List <string> addressList, CodingIncidentMessage codingIncidentMsg) { foreach (string station in addressList) { //If is in connected console //else reply "failed" back to gateway //to prevent from search on an invalid key in the dictionary of connected console if (_ConnectedConsoleList.Contains(station)) { IMessageServiceCallback tmpCallback = _ConnectedConsoleDict[station]; tmpCallback.ConsoleDisplayMsg(codingIncidentMsg); } else { _GatewayCallbackList.ForEach( delegate(IMessageServiceCallback gatewaycallback) { gatewaycallback.NotifyConsoleNotConnected(station, codingIncidentMsg); }); } } }
public void RequestConnStatus() { foreach (string station in _ConnectedConsoleList) { IMessageServiceCallback tmpCallback = _ConnectedConsoleDict[station]; if (((ICommunicationObject)tmpCallback).State == CommunicationState.Opened) { try { tmpCallback.ConsoleRcvConnStatus(); } catch (Exception E) { //Catch those console crash and proxy is still open //trigger to drop this station from connected list } } else { //if aborted or closed still in this list //trigger to drop this station from connected list } } }