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; }
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); }); }
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"); }
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"); }
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); } }
IEnumerable <SquiggleEndPoint> ConvertChatEndPointsForRecipient(IEnumerable <SquiggleEndPoint> endpoints, SquiggleEndPoint recipient) { if (IsLocalChatEndpoint(recipient)) { return(endpoints.Select(ep => new SquiggleEndPoint(ep.ClientID, bridgeEndPointInternal)).ToList()); } return(endpoints); }
public ChatService(SquiggleEndPoint endpoint) { localEndPoint = endpoint; }