real time app with signalr

28
Md. Mojammel Haque

Upload: mojammel-haque

Post on 28-Jan-2018

118 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Real time app with SignalR

Md. Mojammel Haque

Page 2: Real time app with SignalR
Page 3: Real time app with SignalR
Page 4: Real time app with SignalR

persistent connection real-time bi-directional

Page 5: Real time app with SignalR
Page 6: Real time app with SignalR
Page 7: Real time app with SignalR
Page 8: Real time app with SignalR
Page 9: Real time app with SignalR
Page 10: Real time app with SignalR
Page 11: Real time app with SignalR
Page 12: Real time app with SignalR
Page 13: Real time app with SignalR
Page 14: Real time app with SignalR
Page 15: Real time app with SignalR
Page 16: Real time app with SignalR
Page 17: Real time app with SignalR
Page 18: Real time app with SignalR
Page 19: Real time app with SignalR
Page 20: Real time app with SignalR

Consider we have a client side method named MyClientFunc. The server

application will have to call this method. Server will make the call as follows:Clients.Client(id).MyClientFunc()

Page 21: Real time app with SignalR

•Clients:•Clients is a dynamic keyword provided by SignalR.

•Clients contains the list of all connected client of the server.

•Client(id):•Client is also a dynamic keyword provided by SignalR uses to identify the specific client by

is connection Id.

•When a client is connected to the server side application (that is powered by SignalR) are

immediately given a unique id of type Guid. The client can be identified by that id easily.

•MyClientFunc:•The name of the method of Client that will invoke to server

Page 22: Real time app with SignalR

The code go ahead and invoke the method from client to server. The

interaction actually happens over HTTP protocol.

Over HTTP Protocol? What about request-response? How server send

the response without any client request? How server invoke method

from client?

It is possible because SignalR always keeping the persistent connection alive between

client and server. During this connection period there is a dedicated channel is created

between client and server to talk to each other. So if something interesting happen to

the server the server can always push it to client through that channel. Also server can

call the method from client by using that channel.

Page 23: Real time app with SignalR
Page 24: Real time app with SignalR

Consider that we have a function in Server side called MyServerFunc. Now

the client will call it as follows:$.connection.myhub.Server.myServerFunc()

Page 25: Real time app with SignalR

$.connection:

Refers the persistent connection that established by the SignalR between client and

server.

myHub:

This is the name of the Hub class that resides inside server. Client will reach into that

Hub.

A server can have multiple Hubs. So in order to reach into a specific Hub client will

refer the name of that Hub

Server:

Once we reach into the specific hub we can refer the server method by using the

keyword Server.

myServerFunc():

The name of the method that we want to invoke from server to client.

Page 26: Real time app with SignalR

From above discussion we came out a realization that SingalR really abstracts the network transport layer and provides easy APIs on both end.

We don’t have to worry about the network transportation protocols. SingalR automatically figure out the

best transport protocol suited for the communication based on the environments of client and server.

We only maintain the Hub on server side and Hub Proxy on the client side. So we can easily invoke the

method in either end and have easy communication between the client and server.

Page 27: Real time app with SignalR
Page 28: Real time app with SignalR

Contact me at:

[email protected]

Skype: mojamcpds1