Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Asyncore classes #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

added Asyncore classes #37

wants to merge 2 commits into from

Conversation

sphaero
Copy link

@sphaero sphaero commented May 20, 2016

Thanks for your great work! I've added asyncore classes to your module as I needed these. This makes it very easy to integrate this websocket server into existing applications that are based on asyncore (i.e. yowsup)

You can use them as follows:

import asyncore
from SimpleWebSocketServer import AsyncoreWebSocketServer, AsyncoreWebSocketServerHandler

class SimpleAsyncoreEcho(AsyncoreWebSocketServerHandler):

   def handleMessage(self):
      self.sendMessage(self.data)

   def handleConnected(self):
      print('New client connected') 

   def handleClose(self):
      pass

if __name__ == '__main__':
   server = AsyncoreWebSocketServer("", 8000, SimpleAsyncoreEcho)
   asyncore.loop()

@sphaero
Copy link
Author

sphaero commented May 21, 2016

I'm not sure I got the message deque usage correct. Why is there? Is just a buffering mechanism to prevent sending lots of small messages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant