Exemplo n.º 1
0
 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)
     });
 }
Exemplo n.º 2
0
 void OnMessageReceived(Guid sessionId, ISquiggleEndPoint sender, Type messageType)
 {
     MessageReceived(this, new MessageReceivedEventArgs()
     {
         Sender = sender, SessionID = sessionId, Type = messageType
     });
 }
Exemplo n.º 3
0
 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)
     });
 }
Exemplo n.º 4
0
        ChatSession CreateSession(Guid sessionId, ISquiggleEndPoint endpoint)
        {
            ChatSession session = new ChatSession(sessionId, chatHost, localEndPoint, endpoint);

            RegisterSession(session);
            return(session);
        }
Exemplo n.º 5
0
 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()
     });
 }
Exemplo n.º 6
0
        void AskForUserInfo(ISquiggleEndPoint user, UserInfoState state)
        {
            var reply = Message.FromSender <GiveUserInfoMessage>(thisUser);

            reply.State     = (int)state;
            reply.Recipient = new SquiggleEndPoint(user);
            channel.SendMessage(reply);
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 void EnsureChatSession(Guid sessionId, ISquiggleEndPoint user)
 {
     if (!chatSessions.Contains(sessionId))
     {
         var session = CreateSession(sessionId, user);
         ChatStarted(this, new ChatStartedEventArgs()
         {
             Session = session
         });
         session.Initialize(true);
     }
 }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
 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)
     });
 }
Exemplo n.º 12
0
 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)
     });
 }
Exemplo n.º 13
0
 bool IsLocalChatEndpoint(ISquiggleEndPoint recipient)
 {
     return(routeTable.GetLocalChatEndPoint(recipient.ClientID) != null);
 }
Exemplo n.º 14
0
 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
     });
 }
Exemplo n.º 15
0
 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()
     });
 }
Exemplo n.º 16
0
 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)
     });
 }
Exemplo n.º 17
0
 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
     });
 }
Exemplo n.º 18
0
 public void UpdateUser(ISquiggleEndPoint user)
 {
     AddRemoteUser(user);
 }
Exemplo n.º 19
0
 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
     });
 }
Exemplo n.º 20
0
 public void Invite(ISquiggleEndPoint user)
 {
     chatHost.ReceiveChatInvite(Id, localUser, user, RemoteUsers);
 }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
 /// <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);
 }
Exemplo n.º 23
0
 void AddRemoteUser(ISquiggleEndPoint endpoint)
 {
     lock (remoteUsers)
         remoteUsers[endpoint.ClientID] = endpoint;
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
 public void AddLocalPresenceEndPoint(ISquiggleEndPoint localPresenceEndPoint)
 {
     lock (localPresenceEndPoints)
         localPresenceEndPoints[localPresenceEndPoint.ClientID] = localPresenceEndPoint.Address;
 }