private async Task OnActionRequestedAsync(HubAction action)
        {
            switch (action.Name)
            {
            case "requestLogin":
                // response with login
                await DispatchActionAsync(new HubAction { Name = "login", Arguments = "" });

                break;

            case "changePerson":
                // display the same person as the sender of this action
                await RefreshActivePersonAsync(action.Arguments);

                break;

            case "editPerson":
                // start edit mode and bring form to front
                ProcessInUiThread(EditPerson);
                ProcessInUiThread(BringFormToFront);
                ProcessInUiThread(() => SetNotification(""));
                break;

            default:
                break;
            }
        }
Exemple #2
0
        public void HubActionsEncoder_Decode(HubAction expectedAction, string dataAsString)
        {
            // arrange
            var data = BytesStringUtil.StringToData(dataAsString);

            // act
            var message = MessageEncoder.Decode(data, null) as HubActionMessage;

            // assert
            Assert.Equal(expectedAction, message.Action);
        }
Exemple #3
0
        public void HubActionsEncoder_Encode(HubAction action, string expectedData)
        {
            // arrange
            var message = new HubActionMessage(action);

            // act
            var data = MessageEncoder.Encode(message, null);

            // assert
            Assert.Equal(expectedData, BytesStringUtil.DataToString(data));
        }
 /// <summary>
 /// Dispatch a action to the hub, which will notify the other clients.
 /// </summary>
 /// <param name="action"></param>
 private async Task DispatchActionAsync(HubAction action)
 {
     await _hub.Invoke("DispatchAction", action);
 }
 public void DispatchAction(HubAction action)
 {
     // Broadcast incoming action to all OTHER clients
     Clients.Others.ActionRequested(action);
 }
Exemple #6
0
 /// <summary>
 /// Dispatch a action to the hub, which will notify the other clients.
 /// </summary>
 /// <param name="action"></param>
 private void DispatchAction(HubAction action)
 {
     _hub.Invoke("DispatchAction", action);
 }