Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Maya Websocket
import maya.cmds
import maya.utils
from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
from threading import Thread
class SimpleEcho(WebSocket):
def handleMessage(self):
# echo message back to client
#self.sendMessage(maya.utils.executeInMainThreadWithResult(self.data))
self.sendMessage(self.data)
def handleConnected(self):
print(self.address, 'connected')
def handleClose(self):
print(self.address, 'closed')
def start_server():
server = SimpleWebSocketServer('', 8000, SimpleEcho)
server.serveforever()
thread = Thread(target = start_server, args = ())
thread.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment