protected override System.Threading.Tasks.Task OnConnected(IRequest request, string connectionId) { var message = new PageMessage { type = "pageChange", data = _pages[_currentPosition] }; Connection.Send(connectionId, message); return(base.OnConnected(request, connectionId)); }
protected override System.Threading.Tasks.Task OnReceived(IRequest request, string connectionId, string data) { PageMessage message = null; if (data == "next") { _currentPosition++; if (_currentPosition >= _pages.Length) { _currentPosition = _pages.Length - 1; } message = new PageMessage { type = "pageChange", data = _pages[_currentPosition] }; } else if (data == "previous") { _currentPosition--; if (_currentPosition == -1) { _currentPosition = 0; } message = new PageMessage { type = "pageChange", data = _pages[_currentPosition] }; } else { for (int i = 0; i < _pages.Length; i++) { if (_pages[i] == data) { _currentPosition = i; break; } } message = new PageMessage { type = "pageChange", data = data }; } Connection.Broadcast(message); return(base.OnReceived(request, connectionId, data)); }
protected override System.Threading.Tasks.Task OnReceived(IRequest request, string connectionId, string data) { PageMessage message = null; if (data == "next") { _currentPosition++; if (_currentPosition >= _pages.Length) _currentPosition = _pages.Length - 1; message = new PageMessage { type = "pageChange", data = _pages[_currentPosition] }; } else if (data == "previous") { _currentPosition--; if (_currentPosition == -1) _currentPosition = 0; message = new PageMessage { type = "pageChange", data = _pages[_currentPosition] }; } else { for (int i = 0; i < _pages.Length; i++) { if (_pages[i] == data) { _currentPosition = i; break; } } message = new PageMessage { type = "pageChange", data = data }; } Connection.Broadcast(message); return base.OnReceived(request, connectionId, data); }
protected override System.Threading.Tasks.Task OnConnected(IRequest request, string connectionId) { var message = new PageMessage { type = "pageChange", data = _pages[_currentPosition] }; Connection.Send(connectionId, message); return base.OnConnected(request, connectionId); }