I have thoroughly looked at the Chrome packaged app website and sample apps but I couldn't find any example related to websockets implementation in an app. I was wondering if there is any example or sample app that uses Websocket for client/server communication in Chrome app? If not then is there any guide? Is it even possible to use WebSocket? I am using Apache HTTP as my server which is in Python.
I'm assuming you're asking about implementing a WebSocket server, because the browser natively supports the client. (Though if you wanted, you could definitely implement the WebSocket client because you have access to the raw TCP interface.)
The Chrome Apps has published a sample WebSocket chat server that servers HTTP requests to load the chat client and uses WebSockets to send messages between clients.
If you look through the implementation, you see it uses the older chrome.socket API to listen to a TCP socket and respond with the correct WebSocket HTTP headers. It does all the bit manipulation to send and receive frames of data as required by the WebSocket spec.
Related
Hi I have a flask server written in python. I need it to be deployed to a mobile device.The reason for it is that I need the requests to be sent from the client. For that I need the flask app to run natively on the device of the client. I also can't write the requests from the client as I am dealing with httpOnly cookies that can't be seen in the js. I am writing the UI in react native, and I was wondering if there is any solution to my problem? Maybe my react native app will prompt the user to install the apk of the flask server on his device and then the client side will connect to that running server on his device?
My requirement is to communicate socketio with nodejs server to Raspberry Pi running a local Python app. Please help me. I can find ways of communication with web app on google but is there any way to communicate with Python local app with above mentioned requirements.
It's unclear exactly which part you need help with. To make a socket.io connection work, you do the following:
Run a socket.io server on one of your two computers. Make sure it is listening on a known port (it can share a port with a web server if desired).
On the other computer, get a socket.io client library and use that to make a socket.io connection to the other computer.
Register message handlers on both computers for whatever custom messages you intend to send each way and write the code to process those incoming messages.
Write the code to send messages to the other computer at the appropriate time.
Socket.io client and server libraries exist for both node.js and python so you can either type of library for either type of system.
The important things to understand are that you must have a socket.io server up and running. The other endpoint then must connect to that server. Once the connection is up and running, you can then send message from either end to the other end.
For example, you could set up a socket.io server on node.js. Then, use a socket.io client library for python to make a socket.io connection to the node.js server. Then, once the connection is up and running, you are free to send messages from either end to the other and, if you have, message handlers listening for those specific messages, they will be received by the other end.
Using Java one would implement a BroadcastReceiver to use the "Google Cloud Messaging API for Android" and receive GCM multicast messages.
Can the same be achieved with Python (on a PC)? How?
Alternatively is is possible to get the messages on a PC running Ubuntu? (without using Chrome / the PC is a client / server is GAE)
My answer is for GCM implementations. If you are planning a server-and-client setup where the PC is the server (the clients will always be Android devices), you can still receive GCM messages. Instead of downstream messaging (server to client app), it would be upstream (client app to server). To do this, you would need to implement an XMPP setup. There is a Python sample at the bottom of that page.
Quick question: need pure python script of simple http client without using libs (only socket library possible).
Main task of this client is connect to server, receive greetings, sends get requests and read responses. Also it's good if this code will be compatible with Cython compiler.
I would recommend you using requests https://github.com/kennethreitz/requests package.
But your question looks like an assignment which shall teach you how is http working on TCP communication level. In such case I would recommend you
learn using http protocol over telnet or netcat
then learn TCP communication by Python and repeat, what you already know by telnet
I am looking for a web server that has a socket.io server.I want a small server like cherrypy that come with a socket server so that i wont have to modify a lot of things in an existing web server to make the socket server work.
Is there such a web server?.
So you're looking for Websocket support? Gevent with https://bitbucket.org/Jeffrey/gevent-socketio has worked for my purposes.