コード例 #1
0
 /// <summary>
 /// This is called when a client disconnects from the server
 /// Remove the clinet from the collection and broadcast a message to connected clients
 /// </summary>
 /// <param name="request">The request object</param>
 /// <param name="connectionId">The connectionId</param>
 /// <returns></returns>
 protected override Task OnDisconnected(IRequest request, string connectionId)
 {
     _clients.Remove(connectionId);
     var name = _clients[connectionId];
     var shoutBoxData = new ShoutBoxData("Server", string.Format("{0} has stopped shouting!", name));
     return Connection.Broadcast(shoutBoxData);
 }
コード例 #2
0
        public ActionResult PcExample()
        {
            var sbd = new ShoutBoxData();

            return View(sbd);
        }
コード例 #3
0
 /// <summary>
 /// This is called when a client connects to the server. 
 /// Add the clinet to the Dictionary of conected clients, and broadcast a message that a user has joined
 /// </summary>
 /// <param name="request">The request object</param>
 /// <param name="connectionId">The connectionId string</param>
 /// <returns>A Broadcast</returns>
 protected override Task OnConnected(IRequest request, string connectionId)
 {
     _clients.Add(connectionId, string.Empty);
     var shoutBoxData = new ShoutBoxData("Server", "A new user has joined in on the shouting!");
     return Connection.Broadcast(shoutBoxData);
 }