Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. HANUGAMES
    H

    HANUGAMES

    @HANUGAMES

    Chat Follow Unfollow
    0
    Reputation
    2
    Posts
    1015
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Continue chat with HANUGAMES
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    HANUGAMES Follow

    Posts made by HANUGAMES

    Unity OnMessage Handler Error

    OnMessage Code below Down

    	void OnMessage (object sender, MessageEventArgs e)
    	{
    		Debug.Log("OnAddMessages | " +  "|"+ChatUtils.ValueToString(e.message));
    		var message = (IndexedDictionary<string, object>) e.message;
    		Debug.Log(e.message);
    
    	}
    

    and I send

    room.Send("111");

    but after I get response

    InvalidCastException: Specified cast is not valid.
    ColyseusClient.OnMessage (System.Object sender, Colyseus.MessageEventArgs e) (at Assets/PluginsColesus/ColyseusClient.cs:99)
    Colyseus.Room.ParseMessage (System.Byte[] recv) (at Assets/PluginsColesus/Colyseus/Room.cs:195)
    Colyseus.Room.Recv () (at Assets/PluginsColesus/Colyseus/Room.cs:83)
    Colyseus.Client.Recv () (at Assets/PluginsColesus/Colyseus/Client.cs:89)
    ColyseusClient+<Start>d__7.MoveNext () (at Assets/PluginsColesus/ColyseusClient.cs:58)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    Why dont i Get sending data "111".
    Plese check this
    My Unity 2017.3.1f
    Colyseus Latest project .

    posted in General Discussion •
    Issue Get this

    Re: Error: Failed to auto-create room [Unity Client]

    // Use this for initialization
    IEnumerator Start () {
    String uri = "ws://" + serverName + ":" + port;
    Debug.Log (uri);
    client = new Client(uri);
    client.OnOpen += OnOpenHandler;
    client.OnClose += (object sender, EventArgs e) => isConnected = false;

    	Debug.Log ("Let's connect the client!");
    	yield return StartCoroutine(client.Connect());
    
    	Debug.Log ("Let's join the room!");
    	room = client.Join(roomName, new Dictionary<string, object>()
    	{
    		{ "create", true }
    	});
    	room.OnReadyToConnect += (sender, e) => {
    		Debug.Log("Ready to connect to room!");
    		StartCoroutine (room.Connect ());
    	};
    	room.OnJoin += OnRoomJoined;
    	room.OnStateChange += OnStateChangeHandler;
    
    	room.Listen ("players/:id", this.OnPlayerChange);
    	room.Listen ("players/:id/:axis", this.OnPlayerMove);
    	room.Listen ("messages/:number", this.OnMessageAdded);
    

    // room.Listen("messsages", "add", this.OnAddMessages);
    // room.Listen("messsages", "replace", this.OnAddMessages);
    room.Listen (this.OnChangeFallback);

    	room.OnMessage += OnMessage;
    

    //
    int i = 0;

    	while (true)
    	{
    		client.Recv();
    
    		i++;
    
    		if (i % 50 == 0) {
    			room.Send("111");
    
    		}
    
    		yield return 0;
    	}
    }
    
    
    void OnMessage (object sender, MessageEventArgs e)
    {
    	
    	var message = (IndexedDictionary<string, object>) e.message;
    	Debug.Log(e.message);
    }
    
    
    InvalidCastException: Cannot cast from source type to destination type.
    

    ColyseusClient.OnMessage (System.Object sender, Colyseus.MessageEventArgs e) (at Assets/PluginsColesus/ColyseusClient.cs:98)
    Colyseus.Room.ParseMessage (System.Byte[] recv) (at Assets/PluginsColesus/Colyseus/Room.cs:195)
    Colyseus.Room.Recv () (at Assets/PluginsColesus/Colyseus/Room.cs:83)
    Colyseus.Client.Recv () (at Assets/PluginsColesus/Colyseus/Client.cs:89)
    ColyseusClient+<Start>c__Iterator0.MoveNext () (at Assets/PluginsColesus/ColyseusClient.cs:58)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    posted in Questions & Help •