// called when running as guest - host is telling us where to move everybody's mouse cursors public void OnStateFluxMiceChanged(MiceChangedMessage message) { //DebugLog($"SetPlayerMouseDetails: " + JsonUtility.ToJson(message)); if (thisMouse == null) { CreateMousePointerGameObjects(); } foreach (Mouse m in message.Payload.Items) { SetPlayerMouseDetails(m); } }
public Message MiceChange(MiceChangeMessage message) { Player currentPlayer = _websocket.GetCurrentSessionPlayer(); Assert.ThrowIfNull(currentPlayer, "requires a user session", _websocket); GameInstance gameInstance = _websocket.FindPlayerGameInstance(currentPlayer); if (gameInstance != null) { var outgoingMessage = new MiceChangedMessage { Payload = message.Payload }; _websocket.Broadcast(outgoingMessage, currentPlayer.GameInstanceRef, meToo: false); } return(null); }
public void OnStateFluxMiceChanged(MiceChangedMessage msg) { }
IEnumerator ReceiveAndDispatchMessages() { while (!connection.SocketOpenWithIdentity) { foreach (var listener in listeners) { listener.OnStateFluxWaitingToConnect(); } yield return(new WaitForSeconds(1)); } while (true) { openWithIdentity = connection.SocketOpenWithIdentity; if (!connected && openWithIdentity) { connected = true; userName = connection.UserName; foreach (var listener in listeners) { listener.OnStateFluxConnect(); } } else if (connected && !openWithIdentity) { connected = false; userName = ""; foreach (var listener in listeners) { listener.OnStateFluxDisconnect(); } } bool draining = true; int drainingCount = 50; while (draining && (drainingCount--) > 0) { StateFlux.Model.Message message = connection.ReceiveResponse(); draining = (message != null); if (draining) { if (message.MessageType == MessageTypeNames.HostStateChanged) { // FIXME: convert all the others to linq method ForEach listeners.ForEach(l => l.OnStateFluxHostStateChanged((HostStateChangedMessage)message)); } else if (message.MessageType == MessageTypeNames.MiceChanged) { MiceChangedMessage msg = (MiceChangedMessage)message; foreach (var listener in listeners) { listener.OnStateFluxMiceChanged(msg); } } else if (message.MessageType == MessageTypeNames.HostCommandChanged) { HostCommandChangedMessage msg = (HostCommandChangedMessage)message; foreach (var listener in listeners) { listener.OnStateFluxHostCommandChanged(msg); } } else if (message.MessageType == MessageTypeNames.GuestCommandChanged) { GuestCommandChangedMessage msg = (GuestCommandChangedMessage)message; foreach (var listener in listeners) { listener.OnStateFluxGuestCommandChanged(msg); } } else if (message.MessageType == MessageTypeNames.GuestInputChanged) { GuestInputChangedMessage msg = (GuestInputChangedMessage)message; foreach (var listener in listeners) { listener.OnStateFluxGuestInputChanged(msg); } } else if (message.MessageType == MessageTypeNames.PlayerListing) { PlayerListingMessage msg = (PlayerListingMessage)message; foreach (var listener in listeners) { listener.OnStateFluxPlayerListing(msg); } } else if (message.MessageType == MessageTypeNames.GameInstanceCreated) { GameInstanceCreatedMessage msg = (GameInstanceCreatedMessage)message; foreach (var listener in listeners) { listener.OnStateFluxGameInstanceCreated(msg); } } else if (message.MessageType == MessageTypeNames.GameInstanceListing) { GameInstanceListingMessage msg = (GameInstanceListingMessage)message; foreach (var listener in listeners) { listener.OnStateFluxGameInstanceListing(msg); } } else if (message.MessageType == MessageTypeNames.GameInstanceJoined) { GameInstanceJoinedMessage msg = (GameInstanceJoinedMessage)message; foreach (var listener in listeners) { listener.OnStateFluxGameInstanceJoined(msg); } } else if (message.MessageType == MessageTypeNames.GameInstanceStart) { GameInstanceStartMessage msg = (GameInstanceStartMessage)message; Debug.Log($"Game start message, host is {msg.Host.Name}"); Debug.Log($"Current player name is {connection.CurrentPlayer.Name}"); isHosting = (msg.Host.Name == connection.CurrentPlayer.Name); foreach (var listener in listeners) { listener.OnStateFluxGameInstanceStart(msg); } } else if (message.MessageType == MessageTypeNames.GameInstanceStopped) { GameInstanceStoppedMessage msg = (GameInstanceStoppedMessage)message; Debug.Log($"Game stopped message, host is {msg.Host.Name}"); Debug.Log($"Current player name is {connection.CurrentPlayer.Name}"); isHosting = (msg.Host.Name == connection.CurrentPlayer.Name); foreach (var listener in listeners) { listener.OnStateFluxGameInstanceStopped(msg); } } else if (message.MessageType == MessageTypeNames.GameInstanceLeft) { GameInstanceLeftMessage msg = (GameInstanceLeftMessage)message; Debug.Log($"Player {msg.Player.Name} left {msg.GameName}:{msg.InstanceName}"); Debug.Log($"Current player name is {connection.CurrentPlayer.Name}"); foreach (var listener in listeners) { listener.OnStateFluxGameInstanceLeft(msg); } } else if (message.MessageType == MessageTypeNames.ChatSaid) { ChatSaidMessage msg = (ChatSaidMessage)message; foreach (var listener in listeners) { listener.OnStateFluxChatSaid(msg); } } else if (message.MessageType == MessageTypeNames.ServerError) { ServerErrorMessage msg = (ServerErrorMessage)message; foreach (var listener in listeners) { listener.OnStateFluxServerError(msg); } } else { foreach (var listener in listeners) { listener.OnStateFluxOtherMessage(message); } } } } yield return(null); } }