本文整理汇总了C#中IHubProxy.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# IHubProxy.Subscribe方法的具体用法?C# IHubProxy.Subscribe怎么用?C# IHubProxy.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHubProxy
的用法示例。
在下文中一共展示了IHubProxy.Subscribe方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupHub
private async void SetupHub()
{
_hubConnection = new Microsoft.AspNet.SignalR.Client.HubConnection("http://localhost:1331/");
_auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
_auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
_auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
_auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
await _hubConnection.Start();
}
示例2: StartHub
async void StartHub()
{
_hubConnection = new HubConnection("http://192.168.1.148:1331/signalr");
_auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
_auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
_auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
_auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
await _hubConnection.Start();
}
示例3: SetupHub
private async void SetupHub()
{
_updateDelegate = new UpdateBid(UpdateBidMethod);
_updateButtonsDelegate = new UpdateButtons(UpdateButtonsMethod);
_hubConnection = new HubConnection("http://192.168.1.148:1331/");
_auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
_auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
_auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
_auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
await _hubConnection.Start();
}
示例4: StartSignalR
void StartSignalR()
{
if (_hubConnection == null)
{
_hubConnection = new HubConnection(signalRUrl);
_hubProxy = _hubConnection.CreateProxy("MyHub");
_subscription = _hubProxy.Subscribe("executeCommand");
_subscription.Data += data =>
{
Debug.Log(data[0].ToString());
var message = Newtonsoft.Json.JsonConvert.DeserializeObject<Message>(data[0].ToString());
ActionTrigger = message;
};
try
{
_hubConnection.Start();
}
catch (Exception ex)
{
}
}
else
{
Debug.Log("Signalr already connected...");
}
}
示例5: Init
private async void Init()
{
_connection = new HubConnection("http://localhost:54506");
_hub = _connection.CreateHubProxy("chatty");
_hub.Subscribe("spoke").Data += tokens =>
{
var name = tokens[0].ToString();
var message = tokens[1].ToString();
AddMessage(name, message);
};
await _connection.Start();
await _hub.Invoke("setName", "Win8Tomas");
}
示例6: StartSignalR
void StartSignalR()
{
if (_hubConnection == null)
{
_hubConnection = new HubConnection(signalRUrl);
_hubProxy = _hubConnection.CreateProxy("SignalRSampleHub");
_subscription = _hubProxy.Subscribe("broadcastMessage");
_subscription.Data += data =>
{
Debug.Log("signalR called us back");
};
_hubConnection.Start();
}
else
Debug.Log("Signalr already connected...");
}
示例7: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
SetStatus("Connecting");
connection = new HubConnection("http://localhost:8080/chatserver", false);
myHub = connection.CreateHubProxy("ChatHub");
frmLogin login = new frmLogin(myHub);
login.ShowDialog();
connection.Start().ContinueWith(task =>
{
if (task.IsFaulted == false)
{
if (connection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
{
SetStatus("Connected");
myHub.Invoke("Join", login.Username).ContinueWith(task_join =>
{
if (task_join.IsFaulted)
{
MessageBox.Show("Error during joining the server!");
}
else
{
Subscription sub = myHub.Subscribe("addMessage");
sub.Data += args =>
{
Message(args[0].ToString());
};
UpdateUsers();
timer1.Enabled = true;
}
});
}
}
});
}
示例8: Connect
public async static void Connect()
{
var connection = new HubConnection("http://pbclone.azurewebsites.net/");
//var connection = new HubConnection("http://localhost:4341/");
_mainHub = connection.CreateHubProxy("imghub");
await connection.Start().ContinueWith(_ =>
{
_mainHub.Invoke("Create", "test");
//_mainHub.Invoke("SendMsg", "test ok");
//_mainHub.Subscribe("receiveMsg").Data += tokens => Console.WriteLine(tokens[0]);
_mainHub.Subscribe("ReceiveImage").Data += tokens =>
{
byte[] convertedFromBase64 = Convert.FromBase64String(tokens[0].ToString());
Console.WriteLine
(convertedFromBase64.Length);
};
_mainHub.Invoke("ShareImage", new object[] { new byte[] { 1, 2 }, "test" });
});
}
示例9: SubscribeToMessages
protected override void SubscribeToMessages(IHubProxy proxy)
{
proxy.Subscribe("RoomEntered").Data += RoomChange;
proxy.Subscribe("RoomExited").Data += RoomChange;
proxy.Subscribe("OnPlayerTrapped").Data += (object[] args) =>
{
CaughtMessages.Enqueue(new HeistCaughtMessage()
{
Tag = IncomingMessageType.OpponentTrapped,
PlayerId = args[0] as string,
OpponentId = args[1] as string
});
};
proxy.Subscribe("OpponentCaught").Data += (object[] args) =>
{
CaughtMessages.Enqueue(new HeistCaughtMessage()
{
Tag = IncomingMessageType.OpponentCaught,
PlayerId = args[0] as string,
OpponentId = args[1] as string,
});
};
proxy.Subscribe("NeedUpdate").Data += (object[] args) =>
{
NeedsUpdate();
};
proxy.Subscribe("GameFinished").Data += (object[] args) =>
{
UnityEngine.Debug.Log("GAME FINISHED!");
CaughtMessages.Enqueue(new HeistCaughtMessage()
{
Tag = IncomingMessageType.OpponentCaught,
PlayerId = args[0] as string
});
};
proxy.Subscribe("GameReady").Data += (object[] args) =>
{
UnityEngine.Debug.Log("EVERYONE JOINED!");
CaughtMessages.Enqueue(new HeistCaughtMessage()
{
Tag = IncomingMessageType.GameReady,
StartTime = ((DateTime)args[0])
});
};
}
示例10: makeConnection
async private void makeConnection()
{
try
{
// Pass parameter form client to server.
var querystringData = new Dictionary<string, string>();
querystringData.Add("chatversion", "1.1");
var hubConnection = new HubConnection("http://localhost:53748",querystringData);
// Windows authentication.
hubConnection.Credentials = CredentialCache.DefaultCredentials;
// Connection Header.
// hubConnection.Headers.Add("myauthtoken", /* token data */);
//// Auth(Certificate).
//hubConnection.AddClientCertificate(X509Certificate.CreateFromCertFile("MyCert.cer"));
chat = hubConnection.CreateHubProxy("ChatHub");
chatShow.Text = "";
Context = SynchronizationContext.Current;
chat.On<string, string>("broadcastMessage",
(name, message) =>
Context.Post(delegate
{
this.chatShow.Text += name + ": "; this.chatShow.Text += message + "\n";
}, null)
);
chat.Subscribe("notifyWrongVersion").Received += notifyWrongVersion_chat;
await hubConnection.Start();
await chat.Invoke("Notify", chatName.Text, hubConnection.ConnectionId);
}
catch (HubException ex)
{
}
catch (Exception ex)
{
}
}
示例11: SetupHandlers
public override void SetupHandlers(IHubProxy proxy)
{
proxy.Subscribe("send").Received += EchoUser_Received;
}