简体   繁体   English

通过socket.io将python对象发送到node.js

[英]Sending python objects to node.js via socket.io

Ok so what I'd like to do is have a game written in python and for all the multiplayer to be handled socket.io just because these are two things I'm fairly familiar with and I wanna keep possibilities for a web version or web app for the game open 好的,所以我想做的是用Python编写一个游戏,并让所有多人游戏都可以通过socket.io进行处理,因为这是我相当熟悉的两件事,并且我想保留适用于Web版本或Web的可能性打开游戏的应用程序

So what I'm wondering is, how exactly do I do this and would it be better to embed a javascript parser on the client side or contact node.js from python directly 所以我想知道的是,我该怎么做呢?最好在客户端嵌入javascript解析器,或者直接从python与node.js联系

Assuming your Python objects are simple enough (not instances of classes, say), just send a JSON representation ( json.dumps() ) of them to the socket.io side. 假设您的Python对象足够简单(比如说不是类的实例),只需将它们的JSON表示形式( json.dumps() )发送到socket.io即可。 I am assuming you can parse JSON on the client side if needed. 我假设您可以根据需要在客户端解析JSON。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将客户端的 Python 套接字连接到 Node.js/socket.io? - How to connect a Python socket on client-side to Node.js/socket.io? 用于node.js以外的其他平台的Socket.io - Socket.io for other platform than node.js socket.io,发送数据(node.js) - socket.io, send data (node.js) Python socket.io 客户端在 Heroku 上托管后无法向服务器(node.js)发出事件 - Python socket.io client unable to emit event to server(node.js) after hosting on Heroku Python中的代码,在Node.js和Socket.IO中进行通信,以HTML格式呈现 - Code in Python, communicate in Node.js and Socket.IO, present in HTML 是否可以将Node.js socket.io与以python编写的Web应用程序一起使用? - Is it possible to use Node.js socket.io with a web application written in python? 格式化消息以从 python 客户端发送到 socket.io node.js 服务器 - Formatting messages to send to socket.io node.js server from python client 流数据解决方案(Java,Python,socket.io,Node JS) - Solution for streaming data (Java, Python, socket.io, Node JS) node.js socket.io-client + python socketio - node.js socket.io-client + python socketio 如何使用 socket.io 在客户端(网络浏览器)中显示来自 node.js 服务器的实时数据? - How to use socket.io to display realtime data in the client (web browser) from the node.js server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM