Websocket!

#1

Hello!

I'm trying to understand websockets. I have taken one of the demo
included Autobahn. But when I try to use nedansående function, I get
disconnect from the server.

in class
class BroadcastServerFactory(WebSocketServerFactory):

I have added this

def sendMsgToClient(self, client, msg):
        if client in self.clients:
            client.sendMessage(msg)

call occurs when new users log on

in class

class BroadcastServerProtocol(WebSocketServerProtocol):

I have added this

def onOpen(self):

self.factory.sendMsgToClient(self, 'Welcome')

In contrast to broadcast, I try to send a message only to the user
that connects.

Before the user gets the message welcome user get a connection lost

def connectionLost(self, reason):

Someone who can help me? Hope that explanation is sufficient!

Patrik Ekamn
Sweden

0 Likes