private void Client_OnMessageReceived(SignalrUser user) { Device.BeginInvokeOnMainThread(() => { model.Add(user); }); }
public void Connect(string _username) { Connection = new HubConnection(url, new Dictionary <string, string> { { "username", _username } }); Connection.StateChanged += Connection_StateChanged; ChatHubProxy = Connection.CreateHubProxy("ChatHub"); ChatHubProxy.On <string, string>("MessageReceived", (username, message) => { var user = new SignalrUser { username = username, message = message }; OnMessageReceived?.Invoke(user); }); Start().ContinueWith(task => { if (task.IsFaulted) { ConnectionError?.Invoke(); } }); }