Socket.io, connetion works but can't emit
I have this very simple script in Python
import socketio
import eventlet
import eventlet.wsgi
from flask import Flask, render_template
sio = socketio.Server()
app = Flask(__name__)
@sio.on('hello')
def disconnect(sid, data):
print('hello')
if __name__ == '__main__':
app = socketio.Middleware(sio, app)
eventlet.wsgi.server(eventlet.listen(('', 80)), app)
Which basically waits for 'hello' events and prints hello on the console, it works, I've tested it with this tool.
On the other hand Unity does not want to emit correctly, I'm using this asset, I've done as the readme says, moved the prefab to the scene, changed the url so that the port is 8090, added an empty game object with this code:
using SocketIO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StreamControllerScript : MonoBehaviour {
// Use this for initialization
void Start () {
GameObject go = GameObject.Find("SocketIO");
SocketIOComponent socket = go.GetComponent<SocketIOComponent>();
socket.Emit("Hello", JSONObject.CreateStringObject("George"));
}
// Update is called once per frame
void Update () {
}
}
But all I see on the python console is:
(3444) wsgi starting up on http://0.0.0.0:8090
(3444) accepted ('127.0.0.1', 56420)
when instead using the tool I get:
(3444) accepted ('127.0.0.1', 56434)
hello
What can I do to make this asset work correctly? Thanks
Your answer
Follow this Question
Related Questions
Weird string compare behaviour with socket 0 Answers
packet only works with loopback when running send/recv both from unity 0 Answers
get receive from socket wifi 0 Answers
How should I verify that all of my client Object are created and ready after loading a new scene? 0 Answers
[UNET] Transform sycing problem,[UNET] TRANSFORMATION SYCING PROBLEMS 0 Answers