本文整理汇总了C#中IHubProxy类的典型用法代码示例。如果您正苦于以下问题:C# IHubProxy类的具体用法?C# IHubProxy怎么用?C# IHubProxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHubProxy类属于命名空间,在下文中一共展示了IHubProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: 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;
}
});
}
示例3: ConnectAsync
public void ConnectAsync()
{
Connection = new HubConnection("http://54.69.68.144:8733/signalr");
HubProxy = Connection.CreateHubProxy("ChatHub");
//Handle incoming event from server: use Invoke to write to console from SignalR's thread
HubProxy.On<string>("AddMessage", (msg) =>
Console.WriteLine("AddMessage Call: " + msg)
);
HubProxy.On<string>("GetAllMessage", (s) =>
Console.WriteLine(String.Format("{0}: {1}", Environment.NewLine, s))
);
HubProxy.On<int>("GetNumberOfUsers",(s) =>
Console.WriteLine(s)
)
;
try
{
Connection.Start().Wait();
}
catch (HttpRequestException)
{
Console.WriteLine("Unable to connect to server: Start server before connecting clients.");
}
//HubProxy.Invoke("GetAllMessages");
//await HubProxy.Invoke("GetNumberOfUsers");
}
示例4: HubInitial
public void HubInitial()
{
Connection = new HubConnection("http://54.69.68.144:8733/signalr");
HubProxy = Connection.CreateHubProxy("ChatHub");
HubProxy.On<string>("AddMessage",(msg) =>
Device.BeginInvokeOnMainThread(() =>
{
MessageService.AddMessage(msg,false,_controls);
}));
HubProxy.On<int>("GetNumberOfUsers", (count) =>
Device.BeginInvokeOnMainThread(() =>
{
MessageService.SetUsersCount(count, _controls);
}));
try
{
Connection.Start().Wait();
Device.BeginInvokeOnMainThread(() =>
{
_controls.ProgressBar.ProgressTo(.9, 250, Easing.Linear);
});
}
catch (Exception e)
{
MessageTemplate.RenderError("Невозможно подключиться к серверу");
}
HubProxy.Invoke("GetNumberOfUsers");
}
示例5: MainPage
public MainPage()
{
InitializeComponent();
textBlockMessages.Dispatcher.BeginInvoke(new Action(() => textBlockMessages.Text = "This program, SignalRWp7, begins\n"));
hubConnection = new HubConnection("http://localhost:49522/");
hubConnection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
{
Console.WriteLine("Failed to start: {0}", task.Exception.GetBaseException());
}
else
{
Console.WriteLine("Success! Connected with client connection id {0}", hubConnection.ConnectionId);
// Do more stuff here
}
});
hubConnection.Received += data =>
{
HubBub deserializedHubBub = JsonConvert.DeserializeObject<HubBub>(data);
var args0 = deserializedHubBub.Args[0];
UpdateMessages(args0);
};
chatHub = hubConnection.CreateProxy("Chat");
}
示例6: MainWindow
public MainWindow()
{
InitializeComponent();
connection = new HubConnection(@"http://iskenxan-001-site1.btempurl.com/signalr");
myHub = connection.CreateHubProxy("ChatHub");
UserNameTextBox.Focus();
}
示例7: Chat
public Chat(HubConnection connection)
{
_chat = connection.CreateHubProxy("Chat");
_chat.On<User>("markOnline", user =>
{
if (UserOnline != null)
{
UserOnline(user);
}
});
_chat.On<User>("markOffline", user =>
{
if (UserOffline != null)
{
UserOffline(user);
}
});
_chat.On<Message>("addMessage", message =>
{
if (Message != null)
{
Message(message);
}
});
}
示例8: ConnectToServer
public void ConnectToServer()
{
hubConnection = new HubConnection(serverAddress);
hubProxy = hubConnection.CreateHubProxy("SoftNodesHub");
bool isConnected = false;
while (!isConnected)
{
try
{
hubConnection.Start().Wait();
hubConnection.Closed += OnHubConnectionClosed;
//hubProxy.On<Message>("ReceiveMessage", ReceiveMessage);
isConnected = true;
LogInfo("Connected to server");
OnConnected?.Invoke();
}
catch (Exception e)
{
LogError("Connection to server failed: " + e.Message);
OnConnectionFailed?.Invoke(e.Message);
}
}
}
示例9: CoordinateHubClient
public CoordinateHubClient(Action<Coordinate> callback)
{
_hubConnection = new HubConnection("http://indoorgps.azurewebsites.net");
_hubProxy = _hubConnection.CreateHubProxy("CoordinateHub");
_hubProxy.On<Coordinate>("SendNewCoordinate", callback);
_hubConnection.Start().Wait();
}
示例10: Connect
private static void Connect()
{
analyticsWebsiteExceptionHubConnection = new HubConnection(analyticsWebsiteConnectionUrl);
analyticsWebsiteProxy = analyticsWebsiteExceptionHubConnection.CreateHubProxy("ExceptionHub");
analyticsWebsiteExceptionHubConnection.Start().Wait();
analyticsWebsiteConnected = true;
}
示例11: HubConnection
partial void Application_Initialize()
{
HubConnection hubConnection;
http://localhost:49499
hubConnection = new HubConnection("http://localhost:49499"); //make sure it matches your port in development
// HubProxy = hubConnection.CreateProxy("MyHub");
HubProxy = hubConnection.CreateHubProxy("Chat");
HubProxy.On<string, string>("CustomersInserted", (r, user) =>
{
this.ActiveScreens.First().Screen.Details.Dispatcher.BeginInvoke(delegate() {
this.ActiveScreens.First().Screen.ShowMessageBox("han creat un client");
});
// this.Details.Dispatcher.BeginInvoke(() =>
// {
// this.ActiveScreens.First().Screen.ShowMessageBox("han creat un client");
//// Console.WriteLine("Han creat un client");
// });
});
HubProxy.On<string>("addMessage", (missatge) =>
{
this.ActiveScreens.First().Screen.Details.Dispatcher.BeginInvoke(delegate()
{
this.ActiveScreens.First().Screen.ShowMessageBox("has rebut un "+missatge);
});
// this.Details.Dispatcher.BeginInvoke(() =>
// {
// this.ActiveScreens.First().Screen.ShowMessageBox("han creat un client");
//// Console.WriteLine("Han creat un client");
// });
});
hubConnection.Start().Wait();
}
示例12: 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);
});
});
}
示例13: StartConnection
private async void StartConnection()
{
// Connect to the server
try
{
var hubConnection = new HubConnection("http://192.168.0.43:61893/");
// Create a proxy to the 'ChatHub' SignalR Hub
chatHubProxy = hubConnection.CreateHubProxy("ChatHub");
// Wire up a handler for the 'UpdateChatMessage' for the server
// to be called on our client
chatHubProxy.On<string,string>("broadcastMessage", (name, message) => {
var str = $"{name}:{message}\n";
RunOnUiThread(()=> text.Append( str ) );
});
// Start the connection
await hubConnection.Start();
}
catch (Exception e)
{
text.Text = e.Message;
}
}
示例14: CrestLogger
public CrestLogger()
{
var hubConnection = new HubConnection("http://www.contoso.com/");
errorLogHubProxy = hubConnection.CreateHubProxy("ErrorLogHub");
//errorLogHubProxy.On<Error>("LogError", error => { });
hubConnection.Start().Wait();
}
示例15: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
DataContext = App.ViewModel;
var hubConnection = new HubConnection("http://192.168.2.128:50188");
chat = hubConnection.CreateHubProxy("chat");
chat.On<string>("newMessage", msg => Dispatcher.BeginInvoke(() => App.ViewModel.Items.Add(new ItemViewModel { LineOne = msg })));
hubConnection.Error += ex => Dispatcher.BeginInvoke(() =>
{
var aggEx = (AggregateException)ex;
App.ViewModel.Items.Add(new ItemViewModel { LineOne = aggEx.InnerExceptions[0].Message });
});
var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
hubConnection.Start().ContinueWith(task =>
{
var ex = task.Exception.InnerExceptions[0];
App.ViewModel.Items.Add(new ItemViewModel { LineOne = ex.Message });
},
CancellationToken.None,
TaskContinuationOptions.OnlyOnFaulted,
scheduler);
}