How to use Colyseus without authentication?

#1

Hi,

I used the project below to try websocket with defold.

I run it on Defold Engine.
I started the server using “npm start”

And I go this error:

I need to send auth details to ws server?

– My goal is just to run a very simple websocket server with private-rooms.
I don’t need authentication atm. So, can skip JWT and rest of the stuffs.

Please help!

0 Likes

#2

@endel, creator of Colyseus sometimes visits this forum, but your best bet for Colyseus support is in the official Colyseus forum: https://discuss.colyseus.io/

3 Likes

#3

Errr,
Didn’t find any way to switch off authentication.
Also, thought of using same user/pass for all session, but then all will have same username.

So,
Guess I need to keep looking at lua socket and modify python-websocket-server to create a room for each game.

I am only looking for a simple websocket-relay-server with private-rooms.
Player 1 will always be first node (room owner) and act as game-server.
Rest of the players join the room, and keep quite till their turn while receiving updates from game-server node.

Let me know if anyone has already done similar before.
Love to see beautiful codes.
I code old style.

0 Likes

#4

Hi @James_0,

The example on the repository you’ve linked is a bit messy and “tests” a bunch of stuff without any particular order.

There are a few things to get rid of the authentication:

Hope this helps, if you have any further question feel free to join the Colyseus community either the forums or Discord. Cheers!

3 Likes

#5

Thank you

saw this bit too late.
I already modified this python project

For whoever may need this simple approach:

clients = []

rooms = {}
class SimpleChat(WebSocket):

def handleMessage(self):
    
    if self.data[0] == "/":
        if (self.data[1:5] == "join"):
            messageSplit = self.data.split(" ")
            room_name = messageSplit[1]

            if room_name not in rooms:
                rooms[room_name] = []
            
            rooms[room_name].append(self)

            for client in rooms[room_name]:
                print(client.nickname)
                client.sendMessage( u'' + self.nickname +   ' joined the room.')                

            #clients.remove(self)

        elif (self.data[1:5] == "room"):
            print("room received")
            messageSplit = self.data.split("/*^*/")
            room_name = messageSplit[0].split(":")
            room_name = room_name[1]
            message = messageSplit[1]
            
            if room_name not in rooms:
                self.sendMessage( u'' + 'Room does not exists.')
            else:
                for client in rooms[room_name]:
                    client.sendMessage( u'' + self.nickname +   ': ' + message)
0 Likes