void DoHistoryAction(Action <HistoryManager> action) { if (EnableLogging) { ExceptionMonster.EatTheException(() => action(history), "logging history."); } }
void channel_MessageReceived(object sender, MessageReceivedEventArgs e) { ExceptionMonster.EatTheException(() => { if (e.Message is LoginMessage) { OnLoginMessage(e.Message); } else if (e.Message is HiMessage) { OnHiMessage((HiMessage)e.Message); } else if (e.Message is HelloMessage) { OnHelloMessage((HelloMessage)e.Message); } else if (e.Message is UserUpdateMessage) { OnUpdateMessage((UserUpdateMessage)e.Message); } else if (e.Message is GiveUserInfoMessage) { OnGiveUserInfoMessage((GiveUserInfoMessage)e.Message); } else if (e.Message is UserInfoMessage) { OnUserInfoMessage((UserInfoMessage)e.Message); } else if (e.Message is LogoutMessage) { OnLogoutMessage((LogoutMessage)e.Message); } }, "handling presence message in userdiscovery class"); }
public void NotifyTyping() { Task.Run(() => { ExceptionMonster.EatTheException(() => session.NotifyTyping(), "sending typing message"); }); }
async void SignIn(SignInOptions options, bool byUser) { if (context.ChatClient.IsLoggedIn) { return; } busyIndicator.IsBusy = true; Exception ex = null; await Task.Run(() => { clientAvailable.Wait(); SettingsProvider.Current.Load(); var loginHelper = new LoginHelper(context.PluginLoader.AuthenticationProvider, SettingsProvider.Current.Settings, context.ChatClient); ExceptionMonster.EatTheException(() => loginHelper.Login(options), "logging in", out ex); }); busyIndicator.IsBusy = false; if (ex != null && byUser) { MessageBox.Show(ex.Message, Translation.Instance.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } OnSignIn(options); }
async void SignOut(bool byUser) { if (context.ChatClient == null || !context.ChatClient.IsLoggedIn) { return; } clientAvailable.Begin(); // Can't chat with chat service stopped. End all sessions. foreach (var window in chatWindows) { window.EndChat(); } DestroyMonitor(); chatControl.SignIn.DisplayName = context.ChatClient.CurrentUser.DisplayName; chatControl.SignIn.GroupName = context.ChatClient.CurrentUser.Properties.GroupName; await Task.Run(() => { ExceptionMonster.EatTheException(() => context.ChatClient.Logout(), "logging out client"); clientAvailable.End(); }); OnSignout(byUser); }
public void Leave() { Task.Run(() => { ExceptionMonster.EatTheException(() => session.End(), "leaving chat"); LogHistory(EventType.Left, self); }); }
public void Like() { Task.Run(() => { ExceptionMonster.EatTheException(() => session.Like(), "sending like"); LogHistory(EventType.Like, self); }); }
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); }); }
public void SendBuzz() { Task.Run(() => { ExceptionMonster.EatTheException(() => session.SendBuzz(), "sending buzz"); LogHistory(EventType.Buzz, self); }); }
public void SendMessage(Message message) { byte[] data = SerializationHelper.Serialize(message); ExceptionMonster.EatTheException(() => { client.Send(data, data.Length, multicastEndPoint); }, "sending presence mcast message"); }
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"); }
private bool GetRunAtStartup() { bool run = ExceptionMonster.EatTheException(() => { return(WinStartup.IsAdded("squiggle", GetStartupPath())); }, "reading startup info from registry"); return(run); }
public bool Accept() { bool success = ExceptionMonster.EatTheException(() => { ChatHost.AcceptActivityInvite(Id, localUser, remoteUser); }, "accepting activity invite from " + remoteUser); return(success); }
public static void OpenDownloadsFolder() { string downloadsFolder = GetDownloadsFolderPath(); if (Shell.CreateDirectoryIfNotExists(downloadsFolder)) { ExceptionMonster.EatTheException(() => Process.Start(downloadsFolder), "opening downloads folder"); } }
public void SendMessage(Message message) { message.ChannelID = ChannelID; ExceptionMonster.EatTheException(() => { host.Send(message); }, "sending presence message to " + message.Recipient); }
void BeginReceive() { if (started) { ExceptionMonster.EatTheException(() => { client.BeginReceive(OnReceive, null); }, "receiving mcast data on presence channel"); } }
void LogStatus(IBuddy buddy) { if (EnableLogging) { ExceptionMonster.EatTheException(() => { history.AddStatusUpdate(buddy.Id, buddy.DisplayName, (int)buddy.Status); }, "logging history."); } }
void OnInviteReceived(ChatInviteReceivedEventArgs e) { CreateRemoteUsers(e.Participants); ExceptionMonster.EatTheException(() => { BroadCast(endpoint => chatHost.JoinChat(Id, localUser, endpoint)); }, "responding to chat invite"); GroupChatStarted(this, EventArgs.Empty); }
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"); }
public void SendData(byte[] chunk, Action <Exception> onError) { Exception ex; if (!ExceptionMonster.EatTheException(() => { ChatHost.ReceiveActivityData(Id, localUser, remoteUser, chunk); }, "sending data to " + remoteUser.ToString(), out ex)) { onError(ex); } }
public static void Deserialize <T>(byte[] data, Action <T> onDeserialize, string entityName) where T : class { T obj = null; if (ExceptionMonster.EatTheException(() => { obj = SerializationHelper.Deserialize <T>(data); }, "deserializing " + entityName + " of type " + typeof(T).Name)) { onDeserialize(obj); } }
public void Save() { ConfigReader reader = GetConfigReader(); Settings.WriteTo(Properties.Settings.Default, reader); ExceptionMonster.EatTheException(() => { Properties.Settings.Default.Save(); reader.Save(); }, "saving configuration settings"); SettingsUpdated(this, EventArgs.Empty); }
public void Initialize(bool needSessionInfo) { if (needSessionInfo) { ExceptionMonster.EatTheException(() => { chatHost.GetSessionInfo(Id, localUser, PrimaryUser); }, "requesting session info"); } else { OnInitialized(); } }
async void AsyncInvoke(Action action, Action onComplete) { busyIndicator.IsBusy = true; await Task.Run(() => { Exception ex; if (!ExceptionMonster.EatTheException(action, "searching history", out ex)) { MessageBox.Show(ex.Message); } }); onComplete(); busyIndicator.IsBusy = false; }
void chatHost_SessionInfoRequested(object sender, SessionEventArgs e) { if (e.SessionID != Id) { return; } Task.Run(() => { ExceptionMonster.EatTheException(() => { var participants = RemoteUsers.Except(Enumerable.Repeat(e.Sender, 1)).ToArray(); chatHost.ReceiveSessionInfo(Id, localUser, e.Sender, participants); }, "sending session info"); }); }
public void SendMessage(Guid id, string fontName, int fontSize, Color color, FontStyle fontStyle, string message) { Task.Run(() => { Exception ex; if (!ExceptionMonster.EatTheException(() => { session.SendMessage(id, fontName, fontSize, color, fontStyle, message); }, "sending chat message", out ex)) { MessageFailed(this, new MessageFailedEventArgs() { Message = message, Exception = ex }); } LogHistory(EventType.Message, self, message); }); }
public void End() { chatHost.ChatInviteReceived -= chatHost_ChatInviteReceived; chatHost.ActivityInvitationReceived -= chatHost_ActivityInvitationReceived; chatHost.TextMessageReceived -= chatHost_MessageReceived; chatHost.TextMessageUpdated -= chatHost_MessageUpdated; chatHost.UserTyping -= chatHost_UserTyping; chatHost.BuzzReceived -= chatHost_BuzzReceived; chatHost.UserJoined -= chatHost_UserJoined; chatHost.UserLeft -= chatHost_UserLeft; chatHost.SessionInfoRequested -= chatHost_SessionInfoRequested; chatHost.SessionInfoReceived -= chatHost_SessionInfoReceived; ExceptionMonster.EatTheException(() => { BroadCast(endpoint => chatHost.LeaveChat(Id, localUser, endpoint)); }, "sending leave message"); SessionEnded(this, EventArgs.Empty); }
public void UpdateMessage(Guid id, string message) { Task.Run(() => { Exception ex; if (!ExceptionMonster.EatTheException(() => { session.UpdateMessage(id, message); }, "sending chat message update", out ex)) { MessageFailed(this, new MessageFailedEventArgs() { Message = message, Exception = ex }); } LogHistory(EventType.Message, self, message); }); }
private void SetRunAtStartup(bool run) { Exception ex; if (!ExceptionMonster.EatTheException(() => { var runKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); if (run) { WinStartup.Add("squiggle", GetStartupPath()); } else { WinStartup.Remove("squiggle"); } }, "setting squiggle startup option in registry", out ex)) { MessageBox.Show("Could not set Squiggle to run at startup due to exception: " + ex.Message, "Squiggle", MessageBoxButton.OK, MessageBoxImage.Error); } }
void OnReceive(IAsyncResult ar) { byte[] data = null; IPEndPoint remoteEndPoint = null; ExceptionMonster.EatTheException(() => { data = client.EndReceive(ar, ref remoteEndPoint); }, "receiving mcast presence message"); if (data != null) { SerializationHelper.Deserialize <Message>(data, message => { OnMessageReceived(message); }, "presence message"); } BeginReceive(); }