示例#1
0
        public void Login(LoginOptions options)
        {
            string username = options.DisplayName.Trim();

            this.chatEndPoint = new SquiggleEndPoint(CurrentUser.Id, options.ChatEndPoint);
            StartChatService();

            // Some of the users may have gone offline. Lets try to re-discover all the buddies.
            foreach (Buddy buddy in buddies)
            {
                buddy.Status = UserStatus.Offline;
            }

            var presenceOptions = new PresenceServiceOptions()
            {
                ChatEndPoint             = chatEndPoint,
                MulticastEndPoint        = options.MulticastEndPoint,
                MulticastReceiveEndPoint = options.MulticastReceiveEndPoint,
                PresenceServiceEndPoint  = options.PresenceServiceEndPoint,
                KeepAliveTime            = options.KeepAliveTime
            };

            StartPresenceService(username, options.UserProperties, presenceOptions);

            var self = (SelfBuddy)CurrentUser;

            self.Update(UserStatus.Online, options.DisplayName, chatEndPoint.Address, options.UserProperties.ToDictionary());
            self.EnableUpdates = true;
            LogStatus(CurrentUser);

            IsLoggedIn = true;
        }
示例#2
0
文件: Chat.cs 项目: dugu01/squiggle
 public void Invite(IBuddy buddy)
 {
     Task.Run(() =>
     {
         var endpoint = new SquiggleEndPoint(buddy.Id, ((Buddy)buddy).ChatEndPoint);
         ExceptionMonster.EatTheException(() => session.Invite(endpoint), "sending chat invite to " + endpoint);
     });
 }
示例#3
0
 void RouteChatMessageToLocalUser(RouteAction action, SquiggleEndPoint sender, SquiggleEndPoint recipient)
 {
     ExceptionMonster.EatTheException(() =>
     {
         sender = new SquiggleEndPoint(sender.ClientID, bridgeEndPointInternal);
         IPEndPoint endpoint = routeTable.GetLocalChatEndPoint(recipient.ClientID);
         action(true, endpoint, sender, new SquiggleEndPoint(recipient.ClientID, endpoint));
     }, "routing chat message to local user");
 }
示例#4
0
 void RouteMessageToRemoteUser(RouteAction action, SquiggleEndPoint sender, SquiggleEndPoint recipient)
 {
     ExceptionMonster.EatTheException(() =>
     {
         IPEndPoint bridge = routeTable.FindBridge(recipient.ClientID);
         if (bridge != null)
         {
             action(false, bridge, sender, recipient);
         }
     }, "routing message to remote user");
 }
示例#5
0
 void RouteChatMessageToLocalOrRemoteUser(RouteAction action, SquiggleEndPoint sender, SquiggleEndPoint recipient)
 {
     if (IsLocalChatEndpoint(recipient))
     {
         RouteChatMessageToLocalUser(action, sender, recipient);
     }
     else
     {
         RouteMessageToRemoteUser((local, target, s, r) => action(local, target, s, r), sender, recipient);
     }
 }
示例#6
0
 IEnumerable <SquiggleEndPoint> ConvertChatEndPointsForRecipient(IEnumerable <SquiggleEndPoint> endpoints, SquiggleEndPoint recipient)
 {
     if (IsLocalChatEndpoint(recipient))
     {
         return(endpoints.Select(ep => new SquiggleEndPoint(ep.ClientID, bridgeEndPointInternal)).ToList());
     }
     return(endpoints);
 }
示例#7
0
 public ChatService(SquiggleEndPoint endpoint)
 {
     localEndPoint = endpoint;
 }