Hubs Concept
Convention: 慣例,常規,習俗,公約,協定。For example, Coding Convention.
Programming Model
Context: 文章脈絡,事件的來龍去脈
Demo
Hubs Protocol
1. .NET 4.0 doesn’t support WebSocket, so it will use SSE (Server Send Event) as second priority
2. .NET 4.5 support WebSocket, so it will directly use it as first priority
Step 1: Negotiate, try WebSockets
Step 2.1: Connect, with WebSockets, but fail
Step 2.2: Connect again, with SSE, success
If change <httpRuntime targetFramework=”4.5” /> in web.config, WebSocket will be used
Force using LongPolling as transport negociation
Pushing Data: Clients
Clients.Others
Clients.AllExcept(Context.ConnectionId)
above 2 are equal too.
Pushing Data: Groups
Demo – JoinRoom(), SendMessageToRoom()
Hub Lifecycle
Demo
New a class, MonitorHub.cs
GlobalHost.ConnectionManager.GetHubContext<T>();
沒有留言:
張貼留言