private void BroadcastDisconnect()
        {
            var response = new SyncResponse(SyncResponse.ResponseTypes.Disconnect);

            response.Data = new { Reason = "Admin stopped server." };
            this.Broadcast(response.ToString());
        }
        private void HandleCameraSyncProposal(UserContext context, SyncCommand command)
        {
            // Client requests OTHER clients to sync to his camera
            // Re-send data to clients
            var users = command.Data.Users.ToObject <List <User> >();
            //var users = (List<User>)JsonConvert.DeserializeObject<List<User>>(command.Data.Users.ToString());

            var response = new SyncResponse(SyncResponse.ResponseTypes.ProposeSyncCameras);

            response.Data = command.Data;
            var responseString = response.ToString();

            foreach (var user in users)
            {
                var conn = FindConnection(user);
                if (conn != null && conn.ClientAddress == context.ClientAddress.ToString())
                {
                    continue;                                                                         // skip requesting user
                }
                if (conn != null)
                {
                    conn.Context.Send(responseString);
                }
            }
        }
        private void BroadcastUserlist()
        {
            var users = this.State.Users.ToList(); // _users.Where(u => u.IsRegistered).ToList();

            var response = new SyncResponse(SyncResponse.ResponseTypes.UserList);

            response.Data = new { Users = users };
            this.Broadcast(response.ToString());

            this.OnUpdateConnections();
        }
        private void BroadcastState()
        {
            // Copy settings that clients require
            _state.OfftrackLimit = Properties.Settings.Default.OfftrackLimit;

            var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);

            response.Data = new { State = _state };
            Debug.WriteLine(">> Broadcasting state: " + response);

            this.Broadcast(response.ToString());
        }
        private void SendState(UserContext context)
        {
            // Re-send the state if connected
            var conn = this.FindConnection(context);

            if (conn != null && conn.IsRegistered)
            {
                var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);
                response.Data = new { State = _state };
                context.Send(response.ToString());
            }
        }
Example #6
0
 private void BroadcastDisconnect()
 {
     var response = new SyncResponse(SyncResponse.ResponseTypes.Disconnect);
     response.Data = new {Reason = "Admin stopped server."};
     this.Broadcast(response.ToString());
 }
Example #7
0
        private void BroadcastState()
        {
            // Copy settings that clients require
            _state.OfftrackLimit = Properties.Settings.Default.OfftrackLimit;

            var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);
            response.Data = new { State = _state };
            Debug.WriteLine(">> Broadcasting state: " + response);

            this.Broadcast(response.ToString());
        }
Example #8
0
        private void BroadcastUserlist()
        {
            var users = this.State.Users.ToList(); // _users.Where(u => u.IsRegistered).ToList();
            
            var response = new SyncResponse(SyncResponse.ResponseTypes.UserList);
            response.Data = new { Users = users };
            this.Broadcast(response.ToString());

            this.OnUpdateConnections();
        }
Example #9
0
 private void Reply(UserContext context, SyncResponse response)
 {
     context.Send(response.ToString());
 }
Example #10
0
 private void SendState(UserContext context)
 {
     // Re-send the state if connected
     var conn = this.FindConnection(context);
     if (conn != null && conn.IsRegistered)
     {
         var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);
         response.Data = new { State = _state };
         context.Send(response.ToString());
     }
 }
Example #11
0
        private void HandleCameraSyncProposal(UserContext context, SyncCommand command)
        {
            // Client requests OTHER clients to sync to his camera
            // Re-send data to clients
            var users = command.Data.Users.ToObject<List<User>>();
            //var users = (List<User>)JsonConvert.DeserializeObject<List<User>>(command.Data.Users.ToString());

            var response = new SyncResponse(SyncResponse.ResponseTypes.ProposeSyncCameras);
            response.Data = command.Data;
            var responseString = response.ToString();

            foreach (var user in users)
            {
                var conn = FindConnection(user);
                if (conn != null && conn.ClientAddress == context.ClientAddress.ToString()) continue; // skip requesting user
                if (conn != null)
                {
                    conn.Context.Send(responseString);
                }
            }
        }
 private void Reply(UserContext context, SyncResponse response)
 {
     context.Send(response.ToString());
 }