public void HandleChatMessage(object sender, ChatMessage e) { string message = string.Empty; if (e != null) { message = e.Text; } string from = "<unknown>"; if (sender != null) { IChatParticipant senderParticipant = sender as IChatParticipant; if (senderParticipant != null) { from = senderParticipant.Id; } } if (!string.IsNullOrWhiteSpace(message)) { Console.WriteLine($"{this.Id} - message from '{from}'> {message}"); } }
private void OnConnect_AtachToEventSource(IChatParticipant client) { IchatMessageEmiter emiter = client as IchatMessageEmiter; if (emiter == null) { throw new ArgumentException($"Class "); } }
public override void Register(IChatParticipant participant) { if (!_participants.ContainsValue(participant)) { _participants[participant.Name] = participant; } participant.Chatroom = this; }
public static string GetUserIdFromParticipant(IChatParticipant partyParticipant) { var participant = partyParticipant as ChatParticipant; var participantCreator = partyParticipant as ChatParticipantCreator; var participantAdmin = partyParticipant as ChatParticipantAdmin; if (participant != null) { return(participant.UserId.ToString(CultureInfo.InvariantCulture)); } else if (participantCreator != null) { return(participantCreator.UserId.ToString(CultureInfo.InvariantCulture)); } else if (participantAdmin != null) { return(participantAdmin.UserId.ToString(CultureInfo.InvariantCulture)); } return(null); }
public void HandleDisconnectRequest(IChatParticipant client) { if (client == null) { // we don't accept null clients return; } if (!this.participants.ContainsKey(client.Id)) { // client wasn't connected return; } client.OnChatEvent -= this.Client_OnChatEvent; Console.WriteLine($"User '{client.Id}' a iesit"); this.participants.Remove(client.Id); }
public void HandleConnectRequest(IChatParticipant client) { if (client == null) { // we don't accept null clients return; } if (this.participants.ContainsKey(client.Id)) { // client already connected return; } this.participants.Add(client.Id, client); client.OnChatEvent += this.Client_OnChatEvent; Console.WriteLine($"User '{client.Id}' a intrat"); }
public abstract void Register(IChatParticipant participant);
protected virtual void NotifyGroupOnNewConnection(IChatParticipant client) { Console.WriteLine($"User '{client.Id}' has joined the group chat"); }
public MessageIn(IChatParticipant sender, string text) { Sender = sender; Text = text.Trim(); }
public MessageOut(IChatParticipant author, string text, HashSet <IPlayer> listeners = null) { Author = author; Listeners = listeners?.ToImmutableHashSet() ?? ImmutableHashSet <IPlayer> .Empty; Text = text; }
protected virtual void NotifyGroupOnDisconnect(IChatParticipant client) { Console.WriteLine($"User '{client.Id}' has left the group chat"); }