当前位置: 首页>>代码示例>>C#>>正文


C# IHubProxy.Invoke方法代码示例

本文整理汇总了C#中IHubProxy.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# IHubProxy.Invoke方法的具体用法?C# IHubProxy.Invoke怎么用?C# IHubProxy.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHubProxy的用法示例。


在下文中一共展示了IHubProxy.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetHub

        /// <summary>
        /// Hubをセットする
        /// </summary>
        /// <param name="hub"></param>
        public void SetHub(IHubProxy hub)
        {
            if(hub == null) throw new ArgumentNullException(nameof(hub));
            this.hub = hub;
            
            hub.On<string, Type>("serve",async (json, type) =>
              {
                  var noodles = lib.NoodleListConverter.Convert(json, type);
                  if(!noodles.Any()) return;
                  
                  ServedInformation = string.Join("\r\n", ServedInformation, $"{noodles.First().Name}が流れてきたよ!");
                  _flowing = true;

                  try
                  {
                      await Task.Delay(5000);
                      if(!_isPick)
                      {
                          await hub.Invoke("Picking", 0);
                          return;
                      }

                      var pickedCount = Guest.Picking(noodles);
                      ServedInformation = string.Join("\r\n", ServedInformation, Guest.Eat(noodles.Take(pickedCount)));
                      await hub.Invoke("Picking", pickedCount);
                  }
                  finally
                  {
                      _flowing = false;
                      _isPick = false;
                  }
              });
        }
开发者ID:Kazuki-Kachi,项目名称:Madoben,代码行数:37,代码来源:GuestViewModel.cs

示例2: executeCommand

        private static void executeCommand(string address, string command,IHubProxy chat)
        {
            Console.WriteLine(address + " " + command);

            var result = x10Service.SendX10Command(command, address);
            if (result.Success)
            {
                chat.Invoke("DeviceStateChanged", address, command);
            }
            else
            {
                chat.Invoke("DeviceStateChanged", address, command=="on"?"off":"on");
                Logger.Log(result.Error);
            }
        }
开发者ID:erichexter,项目名称:HomeAutomation,代码行数:15,代码来源:X10AgentService.cs

示例3: CommonRH

        public CommonRH(string url,string serverName)
        {
            var querystringData = new Dictionary<string, string>();
            querystringData.Add("name", serverName);

            hubConnection = new HubConnection(url,querystringData);

            rhHubProxy = hubConnection.CreateHubProxy("rhHub");
            

            rhHubProxy.On<int,string,string,string>("daListaEmpresa", (tipoPlataforma, codUtilizador, password,categoria) =>
                daListaEmpresas(tipoPlataforma, codUtilizador, password, categoria)
             );
            

            hubConnection.Start().Wait();
            Console.WriteLine("transport.Name={0}", hubConnection.Transport.Name);
            rhHubProxy.Invoke("message", "ola");
            //hubConnection.TraceWriter.WriteLine("transport.Name={0}", hubConnection.Transport.Name);

            //hubConnection.TraceWriter.WriteLine("Invoking long running hub method with progress...");
            //var result = await hubProxy.Invoke<string, int>("ReportProgress",
            //    percent => hubConnection.TraceWriter.WriteLine("{0}% complete", percent),
            //    /* jobName */ "Long running job");
            //hubConnection.TraceWriter.WriteLine("{0}", result);

            //await hubProxy.Invoke("multipleCalls");
        }
开发者ID:gmahota,项目名称:CRM_MIT,代码行数:28,代码来源:CommonRH.cs

示例4: SetHub

 public async Task SetHub(IHubProxy hub)
 {
     this.hub = hub;
     hub.On<string>("info", info => ServedInformation = string.Join("\r\n", ServedInformation, info));
     hub.On("completed", () => _isCompleted = true);
     await hub.Invoke("SetupServer");
 }
开发者ID:Kazuki-Kachi,项目名称:Madoben,代码行数:7,代码来源:MainPageViewModel.cs

示例5: GameplayScene

        public GameplayScene(GraphicsDevice graphicsDevice)
            : base(graphicsDevice)
        {
            starfield = new Starfield(worldWidth, worldHeight, worldDepth);
            grid = new Grid(worldWidth, worldHeight);
            ShipManager = new ShipManager();
            BulletManager = new BulletManager();
            GameStateManager = new GameStateManager();

            AddActor(ShipManager);
            AddActor(BulletManager);
            AddActor(starfield);
            AddActor(grid);

            #if DEBUG
            hubConnection = new HubConnection("http://localhost:29058");
            #else
            hubConnection = new HubConnection("http://vectorarena.cloudapp.net");
            #endif
            hubProxy = hubConnection.CreateHubProxy("gameHub");
            hubProxy.On("Sync", data => Sync(data));
            hubConnection.Start().ContinueWith(startTask =>
            {
                hubProxy.Invoke<int>("AddPlayer").ContinueWith(invokeTask =>
                {
                    ShipManager.InitializePlayerShip(invokeTask.Result, hubProxy);
                    Camera.TargetObject = ShipManager.PlayerShip;
                    Camera.Position = new Vector3(ShipManager.PlayerShip.Position.X, ShipManager.PlayerShip.Position.Y, 500.0f);
                });
            });
        }
开发者ID:ronforbes,项目名称:VectorArena_bak,代码行数:31,代码来源:GameplayScene.cs

示例6: Init

        private async void Init()
        {
            hubConnection = new HubConnection("http://localhost:5225");
            proxy = hubConnection.CreateHubProxy("MyHub");
            await hubConnection.Start();

            proxy.On<string>("executeCommand", (data) =>
            {
                Debug.WriteLine(data);
               // var message = Newtonsoft.Json.JsonConvert.DeserializeObject<Message>(data.ToString());
            });

            qmhubConnection = new HubConnection("http://quantifymewebhub.azurewebsites.net/");
            qmproxy = qmhubConnection.CreateHubProxy("QuantifyMeHub");
            await qmhubConnection.Start();

            qmproxy.On<string,string>("send", (name, data) =>
            {
                Debug.WriteLine(data);
                var message = new Message { Source = "RemoteUWP", Action = "UpdateData", Value = data };

                proxy.Invoke("Send", Newtonsoft.Json.JsonConvert.SerializeObject(message));

            });
        }
开发者ID:valeryjacobs,项目名称:TIMTLTS,代码行数:25,代码来源:MainPage.xaml.cs

示例7: Notify

        public async void Notify(ISubcriber subcriber, BaseNotifierData data)
        {
            var signalrSubcriber = subcriber as SignalRSubcriber;
            var signalrData = data as MessageNotifierData;

            if (signalrSubcriber == null || signalrData == null)
                throw new AntelopeInvalidParameter();

            try
            {
                _connection = new HubConnection(signalrSubcriber.Url);

                _proxy = _connection.CreateHubProxy(HubName());

                _connection.Closed += OnConnectionClosed;

                await _connection.Start();
            }
            catch (HttpRequestException)
            {
                _logger.Info("Can't connect to {0}", signalrSubcriber.Url);
            }

            await _proxy.Invoke(HubMethod(), Formatter.Format(signalrData.Content));           
        }
开发者ID:quangnle,项目名称:Antelope,代码行数:25,代码来源:SignalRNotifier.cs

示例8: Main

        static void Main(string[] args)
        {
            Console.Write("Enter your Name: ");
            name = Console.ReadLine();

            HubConnection connection = new HubConnection("http://localhost:51734");
            proxy = connection.CreateHubProxy("ChatHub");

            connection.Received += Connection_Received;

            Action<string, string> SendMessageRecieved = recieved_a_message;

            proxy.On("broadcastMessage", SendMessageRecieved);

            Console.WriteLine("Waiting for connection");
            connection.Start().Wait();
            Console.WriteLine("You can send messages now.");

            connection.StateChanged += Connection_StateChanged;

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                proxy.Invoke("Send", new object[] { name, input });
            }
        }
开发者ID:AlexRex,项目名称:CasualGaming--SignalRChatEx2015,代码行数:26,代码来源:Program.cs

示例9: OpenConnection

        private async Task OpenConnection()
        {
            var url = $"http://{await _serverFinder.GetServerAddressAsync()}/";

            try
            {
                _hubConnection = new HubConnection(url);

                _hubProxy = _hubConnection.CreateHubProxy("device");
                _hubProxy.On<string>("hello", message => Hello(message));
                _hubProxy.On("helloMsg", () => Hello("EMPTY"));
                _hubProxy.On<long, bool, bool>("binaryDeviceUpdated", (deviceId, success, binarySetting) => InvokeDeviceUpdated(deviceId, success, binarySetting: binarySetting));
                _hubProxy.On<long, bool, double>("continousDeviceUpdated", (deviceId, success, continousSetting) => InvokeDeviceUpdated(deviceId, success, continousSetting));

                await _hubConnection.Start();

                await _hubProxy.Invoke("helloMsg", "mobile device here");

                Debug.WriteLine($"{nameof(RealTimeService)}.{nameof(OpenConnection)} SignalR connection opened");
            }
            catch (Exception e)
            {
                Debug.WriteLine($"{nameof(RealTimeService)}.{nameof(OpenConnection)} ex: {e.GetType()}, msg: {e.Message}");
            }
        }
开发者ID:rwojcik,项目名称:imsClient,代码行数:25,代码来源:RealTimeService.cs

示例10: StartRealtimeConnection

        private async Task<ApiResultBase> StartRealtimeConnection(ConnectExtruderModel connectExtruderModel)
        {
            try
            {
                _connection = new HubConnection(SOS_URL);
                _proxy = _connection.CreateHubProxy("SosHub");

                _proxy.On<int?, TimeSpan?>("setLights", OnSetLightsEventReceived);
                _proxy.On<int?, TimeSpan?>("setAudio", OnSetAudioEventReceived);
                _proxy.On<ModalDialogEventArgs>("modalDialog", OnModalDialogEventReceived);
                _proxy.On("forceDisconnect", OnForceDisconnect);
                _proxy.On<TrayIcon>("setTrayIcon", OnSetTrayIcon);
                _proxy.On<TrayNotifyEventArgs>("trayNotify", OnTrayNotify);
                _connection.Error += ConnectionOnError;
                _connection.StateChanged += ConnectionOnStateChanged;
                _connection.Closed += ConnectionOnClosed;
                await _connection.Start();
                var result = await _proxy.Invoke<ApiResultBase>("connectExtruder", connectExtruderModel);
                if (!result.Success)
                {
                    _connection.Stop();
                }
                return result;
            }
            catch (Exception ex)
            {
                _log.Error("Unable to start realtime connection to SoS Online", ex);
                return new ApiResultBase {Success = false, ErrorMessage = ex.Message};
            }
        }
开发者ID:AutomatedArchitecture,项目名称:SirenOfShame,代码行数:30,代码来源:SosOnlineService.cs

示例11: Enviar

        private static void Enviar(IHubProxy _hub, string nome)
        {
            var mensagem = Console.ReadLine();
            _hub.Invoke("Send", nome, mensagem).Wait();

            Enviar(_hub, nome);
        }
开发者ID:viniciusoreis,项目名称:XSP-SignalR,代码行数:7,代码来源:Program.cs

示例12: SetupSignalRConnection

        private async Task SetupSignalRConnection()
        {
            _connection = new HubConnection("http://pbclone.azurewebsites.net/");
            _connection.StateChanged += ConnectionOnStateChanged;
            _mainHub = _connection.CreateHubProxy("imghub");

            await _connection.Start();

            _mainHub.Invoke("Create", _guid);
        }
开发者ID:NicoVermeir,项目名称:photobeamerclone,代码行数:10,代码来源:MainPage.xaml.cs

示例13: Invoke

 private static void Invoke(IHubProxy proxy, string method, string username) {
     Console.WriteLine("\nCalling server method " + method + " as " + username);
     try {
         proxy.Invoke(method, username + " invoked " + method + "() from console!").Wait();
     } catch (AggregateException ex) {
         foreach (var innerException in ex.InnerExceptions) {
             Console.WriteLine("    * " + innerException.Message);
         }
     }
 }
开发者ID:Geronimobile,项目名称:DotNetExamIntro,代码行数:10,代码来源:Program.cs

示例14: SaveUserMaps

        public static async Task SaveUserMaps(IHubProxy HubProxy, UserMaps usrMaps)
        {
            try
            {
                await HubProxy.Invoke<UserMaps>("SaveUserMaps", usrMaps);
            }
            catch (Exception ex)
            {
            }

        }
开发者ID:ohadmanor,项目名称:TDS,代码行数:11,代码来源:SAGSignalR.cs

示例15: StartAsync

 public async Task StartAsync()
 {
     hubConnection = new HubConnection(Url);
     eventHubProxy = hubConnection.CreateHubProxy("EventHub");
     eventHubProxy.On<Message>("Receive",
         async message => await FilterMessage(message, async () => await OnReceive(message)));
     eventHubProxy.On<Message>("UpdateConfiguration",
         async message => await FilterMessage(message, async () => await OnUpdateConfiguration(message.Values["Locations"] as IEnumerable<Location>)));
     await hubConnection.Start();
     await eventHubProxy.Invoke<Message>("RequestConfiguration");
 }
开发者ID:wertzui,项目名称:HomeController,代码行数:11,代码来源:HubClient.cs


注:本文中的IHubProxy.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。