diff options
| author | Michael <[email protected]> | 2017-02-13 13:12:51 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-13 13:12:58 -0500 |
| commit | d3a70b7a39bf1c73ff0463a8f06c82359a672bb0 (patch) | |
| tree | 9133ed712cafeec872ca5010bc4e1823726fcc5d /ShiftOS.WinForms/Applications | |
| parent | 15cf720b7e0042f8e0fc30d23ac4c468a39a5a42 (diff) | |
| download | shiftos_thereturn-d3a70b7a39bf1c73ff0463a8f06c82359a672bb0.tar.gz shiftos_thereturn-d3a70b7a39bf1c73ff0463a8f06c82359a672bb0.tar.bz2 shiftos_thereturn-d3a70b7a39bf1c73ff0463a8f06c82359a672bb0.zip | |
Discord Integration client-side
Diffstat (limited to 'ShiftOS.WinForms/Applications')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Chat.cs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index 14eb023..48b40de 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -50,10 +50,17 @@ namespace ShiftOS.WinForms.Applications { this.Invoke(new Action(() => { - - var cmsg = JsonConvert.DeserializeObject<ShiftOS.Objects.ChatMessage>(msg.Contents); - if(id == cmsg.Channel) - rtbchat.AppendText($"[{cmsg.Username}@{cmsg.SystemName}] {cmsg.Message}{Environment.NewLine}"); + try + { + var args = JsonConvert.DeserializeObject<Dictionary<string, string>>(msg.Contents); + var cmsg = new ShiftOS.Objects.ChatMessage(args["Username"] as string, args["SystemName"] as string, args["Message"] as string, args["Channel"] as string); + if (id == cmsg.Channel) + rtbchat.AppendText($"[{cmsg.Username}@{cmsg.SystemName}] {cmsg.Message}{Environment.NewLine}"); + } + catch (Exception ex) + { + rtbchat.AppendText($"[system@multiuserdomain] Exception thrown by client: {ex}"); + } })); } catch { } @@ -63,6 +70,8 @@ namespace ShiftOS.WinForms.Applications public void SendMessage(string msg) { + rtbchat.AppendText($"[{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}] {msg}{Environment.NewLine}"); + ServerManager.SendMessage("chat_send", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatMessage(SaveSystem.CurrentSave.Username, SaveSystem.CurrentSave.SystemName, msg, id))); } |
