public static void GetSessionInfo(this ChatHost host, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient) { host.Send(new GiveSessionInfoMessage() { SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient) }); }
void OnMessageReceived(Guid sessionId, ISquiggleEndPoint sender, Type messageType) { MessageReceived(this, new MessageReceivedEventArgs() { Sender = sender, SessionID = sessionId, Type = messageType }); }
public static void UserIsTyping(this ChatHost host, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient) { host.Send(new UserTypingMessage() { SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient) }); }
ChatSession CreateSession(Guid sessionId, ISquiggleEndPoint endpoint) { ChatSession session = new ChatSession(sessionId, chatHost, localEndPoint, endpoint); RegisterSession(session); return(session); }
public static void ReceiveSessionInfo(this ChatHost host, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient, ISquiggleEndPoint[] participants) { host.Send(new SessionInfoMessage() { SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient), Participants = participants.Select(p => new SquiggleEndPoint(p)).ToList() }); }
void AskForUserInfo(ISquiggleEndPoint user, UserInfoState state) { var reply = Message.FromSender <GiveUserInfoMessage>(thisUser); reply.State = (int)state; reply.Recipient = new SquiggleEndPoint(user); channel.SendMessage(reply); }
private ActivitySession(Guid chatSessionId, ChatHost chatHost, ISquiggleEndPoint localUser, ISquiggleEndPoint remoteUser, Guid Id, bool selfInitiated) { this.chatSessionId = chatSessionId; this.ChatHost = chatHost; this.localUser = localUser; this.remoteUser = remoteUser; this.Id = Id; this.SelfInitiated = selfInitiated; }
public IChatSession CreateSession(ISquiggleEndPoint endPoint) { IChatSession result = chatSessions.Find(s => !s.IsGroupSession && s.RemoteUsers.Contains(endPoint)); if (result == null) { var session = CreateSession(Guid.NewGuid(), endPoint); session.Initialize(false); result = session; } return(result); }
void EnsureChatSession(Guid sessionId, ISquiggleEndPoint user) { if (!chatSessions.Contains(sessionId)) { var session = CreateSession(sessionId, user); ChatStarted(this, new ChatStartedEventArgs() { Session = session }); session.Initialize(true); } }
public ChatSession(Guid sessionID, ChatHost localHost, ISquiggleEndPoint localUser, ISquiggleEndPoint remoteUser) { this.Id = sessionID; this.chatHost = localHost; this.localUser = localUser; localHost.ChatInviteReceived += chatHost_ChatInviteReceived; localHost.ActivityInvitationReceived += chatHost_ActivityInvitationReceived; localHost.TextMessageReceived += chatHost_MessageReceived; localHost.TextMessageUpdated += chatHost_MessageUpdated; localHost.UserTyping += chatHost_UserTyping; localHost.BuzzReceived += chatHost_BuzzReceived; localHost.UserJoined += chatHost_UserJoined; localHost.UserLeft += chatHost_UserLeft; localHost.SessionInfoRequested += chatHost_SessionInfoRequested; localHost.SessionInfoReceived += chatHost_SessionInfoReceived; remoteUsers = new Dictionary <string, ISquiggleEndPoint>(); CreateRemoteUsers(Enumerable.Repeat(remoteUser, 1)); }
public static void ReceiveActivityInvite(this ChatHost host, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient, Guid activityId, Guid activitySessionId, IEnumerable <KeyValuePair <string, string> > metadata) { host.Send(new ActivityInviteMessage() { SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient), ActivityId = activityId, ActivitySessionId = activitySessionId, Metadata = metadata.ToDictionary(kv => kv.Key, kv => kv.Value) }); }
public static void LeaveChat(this ChatHost host, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient) { host.Send(new ChatLeaveMessage() { SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient) }); }
bool IsLocalChatEndpoint(ISquiggleEndPoint recipient) { return(routeTable.GetLocalChatEndPoint(recipient.ClientID) != null); }
public static void UpdateMessage(this ChatHost host, Guid messageId, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient, string message) { host.Send(new UpdateTextMessage() { Id = messageId, SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient), Message = message }); }
public static void ReceiveChatInvite(this ChatHost host, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient, IEnumerable <ISquiggleEndPoint> participants) { host.Send(new ChatInviteMessage() { SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient), Participants = participants.Select(p => new SquiggleEndPoint(p)).ToList() }); }
public static void CancelActivitySession(this ChatHost host, Guid activitySessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient) { host.Send(new ActivityCancelMessage() { SessionId = activitySessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient) }); }
public static void ReceiveMessage(this ChatHost host, Guid messageId, Guid sessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient, string fontName, int fontSize, Color color, FontStyle fontStyle, string message) { host.Send(new TextMessage() { Id = messageId, SessionId = sessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient), FontName = fontName, FontSize = fontSize, Color = color, FontStyle = fontStyle, Message = message }); }
public void UpdateUser(ISquiggleEndPoint user) { AddRemoteUser(user); }
public static void ReceiveActivityData(this ChatHost host, Guid activitySessionId, ISquiggleEndPoint sender, ISquiggleEndPoint recipient, byte[] chunk) { host.Send(new ActivityDataMessage() { SessionId = activitySessionId, Sender = new SquiggleEndPoint(sender), Recipient = new SquiggleEndPoint(recipient), Data = chunk }); }
public void Invite(ISquiggleEndPoint user) { chatHost.ReceiveChatInvite(Id, localUser, user, RemoteUsers); }
public static ActivitySession Create(Guid sessionId, ChatHost chatHost, ISquiggleEndPoint localUser, ISquiggleEndPoint remoteUser) { var session = new ActivitySession(sessionId, chatHost, localUser, remoteUser, Guid.NewGuid(), true); return(session); }
/// <summary> /// Asks user to return his presence information. Can be used to get latest update about user presence or to inquire details about discovered users. /// </summary> /// <param name="user">The presence endpoint of user.</param> /// <param name="discovered">If True, UserUpdated event is fired on completion, otherwise UserDiscovered.</param> public void UpdateUser(ISquiggleEndPoint user, bool discovered) { AskForUserInfo(user, discovered ? UserInfoState.PresenceDiscovered : UserInfoState.Update); }
void AddRemoteUser(ISquiggleEndPoint endpoint) { lock (remoteUsers) remoteUsers[endpoint.ClientID] = endpoint; }
bool IsRemoteUser(ISquiggleEndPoint user) { lock (remoteUsers) return(remoteUsers.ContainsKey(user.ClientID)); }
public SessionEventArgs(Guid sessionId, ISquiggleEndPoint user) { this.SessionID = sessionId; this.Sender = user; }
public SquiggleEndPoint(ISquiggleEndPoint other) { Address = other.Address; ClientID = other.ClientID; }
public static ActivitySession FromInvite(Guid sessionId, ChatHost chatHost, ISquiggleEndPoint localUser, ISquiggleEndPoint remoteUser, Guid activitySessionId) { var session = new ActivitySession(sessionId, chatHost, localUser, remoteUser, activitySessionId, false); return(session); }
public void AddLocalPresenceEndPoint(ISquiggleEndPoint localPresenceEndPoint) { lock (localPresenceEndPoints) localPresenceEndPoints[localPresenceEndPoint.ClientID] = localPresenceEndPoint.Address; }