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

pyhton API: where does "42" prefix come from? #6

Open
RomanBrodetski opened this issue Dec 8, 2017 · 2 comments
Open

pyhton API: where does "42" prefix come from? #6

RomanBrodetski opened this issue Dec 8, 2017 · 2 comments

Comments

@RomanBrodetski
Copy link

tosend = '42["getMarket",{"token":"' + self.token + '","user":"' + self.userAccount + '"}]'

Here it seems like all the method invocations contain a leading "42" number. I didn't find this described in the docs. Where does it come from?
I'm trying to replicate the python client behaviour using scala and akka-http without much luck. I keep ending up with the following response:

0{"sid":"ndWNgwRDSzvcRkioAABg","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
40

cc @tomvanbraeckel

@RomanBrodetski
Copy link
Author

I figured out that the API provided is not plain websockets API. It's socket.io API with only websocket transport enabled (It would be nice to edit the API description to reflect this fact).

These "42" numbers is what socket.io uses for namespacing.

@mshenfield
Copy link

Linking some resources for future users:

  • First number is the packet type - used to determine the type of protocol request being made (4 is a message)
  • Second number is the message object type - the type of the message. "2" is a socket.io Event (the type of thing you on(event, callback)).

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

No branches or pull requests

2 participants