/// <summary> /// Registers that the given Character has now logged in /// </summary> /// <param name="characterName">Name of the Character.</param> /// <param name="accountName">Account of the Character to login.</param> public bool ConnectCharacter(string characterName, string accountName) { try { // character cant connect twice if (ConnectedCharacters.ContainsKey(characterName)) { Logger.Log.DebugFormat($"[WCF] Character {characterName} is already connected."); return(false); } else { // TODO: move in own method, cannot do this here because it needs to be called by // a client who wants to know if the character is allowed to connect // without doing it actually Logger.Log.DebugFormat($"[WCF] Character {characterName} has connected."); ConnectedCharacters.Add(characterName, accountName); return(true); } } catch (Exception ex) { Logger.Log.Error("General Error", ex); return(false); } }
/// <summary> /// Registers that the given Character has now logged in /// </summary> /// <param name="characterName">Name of the Character.</param> /// <param name="accountName">Account of the Character to login.</param> public bool ConnectCharacter(string characterName, string accountName) { try { // character cant connect twice if (ConnectedCharacters.ContainsKey(characterName)) { Logger.Log.DebugFormat($"[WCF] Character {characterName} is already connected."); return(false); } else { // TODO: move in own method, cannot do this here because it needs to be called by a client who wants to know if the // character is allowed to connect without doing it actually Logger.Log.DebugFormat($"[WCF] Character {characterName} has connected."); ConnectedCharacters.Add(characterName, accountName); // inform clients ICommunicationCallback callback = OperationContext.Current.GetCallbackChannel <ICommunicationCallback>(); callback.ConnectCharacterCallback(characterName); return(true); } } catch (Exception ex) { Logger.Log.Error("General Error", ex); return(false); } }
/// <summary> /// Disconnect character from server. /// </summary> /// <param name="characterName">Character who wants to disconnect.</param> public void DisconnectCharacter(string characterName) { try { ConnectedCharacters.Remove(characterName); Logger.Log.DebugFormat($"[WCF] Character {characterName} has been disconnected."); } catch (Exception ex) { Logger.Log.Error("General Error", ex); } }
/// <summary> /// Disconnect character from server. /// </summary> /// <param name="characterName">Character who wants to disconnect.</param> public void DisconnectCharacter(string characterName) { try { ConnectedCharacters.Remove(characterName); // inform clients ICommunicationCallback callback = OperationContext.Current.GetCallbackChannel <ICommunicationCallback>(); callback.DisconnectCharacterCallback(characterName); Logger.Log.DebugFormat($"[WCF] Character {characterName} has been disconnected."); } catch (Exception ex) { Logger.Log.Error("General Error", ex); } }