Socket.IO werfen Typ Fehler

Ich habe einen einfachen NodeJS server, der verwendet bcrypt -, mysql-und-socket.IO, das funktioniert als gateway für eine mysql-Datenbank und einen chat-server. Dieser server verbindet sich der client mit Buchse.IO-client, und sendet Anfragen an den server mittels Socket.E /a-Ereignisse. Die Eintragung Ereignis wirft ein Type Error : undefined is not a function. Ich habe alle Funktionen und es gibt Sie, ich weiß also nicht, was passiert ist. Hier ist mein code für die Registrierung Veranstaltung :

socket.on('registration request', function(msg,err) {
        var split = msg.toString().split(":§:");
        var userName = split[0];
        var password = split[1];
        var email = split[2];

        console.log("Registration request : " + userName + " <===> " + email); //<====== Prints this to the console then crashes and returns the message below
        if(err){
            console.log("Socket Error !!\n" + err);
        }
        if (pattern.test(userName) && emailRegex.test(email)) {
            console.log("Data is valid. Coding password");
            password = bcrypt.hashSync(password.toString(), 2);
            console.log("Querying DB");
            DBConnection.query(
                    "INSERT INTO users (user_name,user_password,user_email) VALUES (\""
                            + userName + "\" , \"" + password + "\" , \""
                            + email + "\");", function(error, rows) {
                        if (error) {
                            console.log("Something went wrong in registering " + userName);
                            sIO.sockets.socket(socket.id).emit('registration response', "<ERROR>");
                        } else if (rows.length > 1) {
                            console.log("Registration of " + userName + " succeded");
                            sIO.sockets.socket(socket.id).emit('registration response', "<SUCCESS>");
                        } else {
                            console.log("Registration of " + userName + "denied")
                            sIO.sockets.socket(socket.id).emit('registration response', "<DENIED>");
                        }
                    });
        } else {
            socket.emit('registration response', "<DENIED>");
        }
    });

Und hier ist die Fehlermeldung :

Missing error handler on `socket`.
TypeError: undefined is not a function
    at Socket.<anonymous> (/root/ChatServer/index.js:109:15)
    at Socket.emit (events.js:107:17)
    at Socket.onevent (/root/ChatServer/node_modules/socket.io/lib/socket.js:330:8)
    at Socket.onpacket (/root/ChatServer/node_modules/socket.io/lib/socket.js:290:12)
    at Client.ondecoded (/root/ChatServer/node_modules/socket.io/lib/client.js:193:14)
    at Decoder.Emitter.emit (/root/ChatServer/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
    at Decoder.add (/root/ChatServer/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
    at Client.ondata (/root/ChatServer/node_modules/socket.io/lib/client.js:175:18)
    at Socket.emit (events.js:107:17)
    at Socket.onPacket (/root/ChatServer/node_modules/socket.io/node_modules/engine.io/lib/socket.js:99:14)

Ich kann nicht finden, mein Fehler. Ihre Hilfe wäre sehr apreciated.

InformationsquelleAutor adre76 | 2015-03-03
Schreibe einen Kommentar