public void Connect(string _username) { Connection = new HubConnection(BASE_URL, new Dictionary <string, string> { { "username", _username } }); Proxy = Connection.CreateHubProxy("ChatHub"); Proxy.On <string, string>("GetMessage", (username, message) => { OnGetMessage?.Invoke(username, message); }); Proxy.On <string>("GetMe", (message) => { OnGetMyMessage?.Invoke(message); }); Proxy.On <string>("GetInfo", (info) => { OnGetInfo?.Invoke(info); }); Start().ContinueWith(task => { if (task.IsFaulted) { ConnectionErrorOcurned?.Invoke(); } }); }
protected void NotifyListener(string message) { if (message != string.Empty) { OnGetMessage?.Invoke(message); } }
//Gets Called When The Server Send Status.Message void GetMessage(Message msg) { switch (msg.Type) { case MessageType.Global: OnGetMessage?.Invoke(msg); break; case MessageType.Private: PrivateChat.GetMessage((Message <int>)msg); break; case MessageType.Group: GroupChat.GetMessage((Message <Guid>)msg); break; } }
private void MessageSender_OnRead(object sender, string e) { OnGetMessage?.Invoke(sender, e); }