Linked Questions

Popular Questions

I'm attempting to create a simple multiplayer connection between a server and a client. The server is not on a webpage. The server prints logs that it's running and it detects when a player connects and disconnects and writes logs like it's supposed to. When a player connects the server should theoretically send an id out to the client and when the client receives this the emitterListener should println the id, but the emitterListener never fires off and the log prints out several messages that all say: (HTTPLog)-Static: isSBSettingEnabled false

I'm following a tutorial: https://www.youtube.com/watch?v=0t2wlvBJBUw&index=4&list=PLZm85UZQLd2Qh6r7jxBKPuB4hl-Xw5uZT and I've triple checked that I've written everything correctly. I tried looking up (HTTPLog)-Static: isSBSettingEnabled false and based on what I've read it's a Samsung exclusive problem that has to do with the url but I've found no solutions. The url I use is http://myIpAdress:8080.

The Server:

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

server.listen(8080, function(){
       console.log("Server is now running");//This prints
});

io.on('connection', function(socket){
       console.log("Player Connected");//This prints
       socket.emit('socketID', { id: socket.id });
       socket.on('disconnect', function(){
            console.log("player disconnected");//This prints
       });
});

The code inside my main class:

private void connectSocket(){
        try{
            socket = IO.socket("http://---.---.--.-:8080");
            socket.connect();
        } catch (Exception e){
            System.out.println("error: " + e);
        }
    }




private void configSocketEvents(){
        socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                System.out.println("socket.io, Connected");//This prints
            }
        }).on("socketID", new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                System.out.println("Is this running?");///Doesn't print
                JSONObject data =(JSONObject) args[0];
                try {
                    String id = data.getString("id");
                    System.out.println("SocketIO, My ID: " + id);
                } catch (JSONException e) {
                    System.out.println("Socket.IO, JSONException " + e.toString());
                }
            }
        });
    }

I expect the system to print out the clients id when a connection is made but it is apparent that socket.emit is not working possibly due to an issue with the url.

Related Questions