2

Mentioning above, I want to know about the meaning of special character in socket.io api document, link below. https://github.com/Automattic/socket.io#serversrvhttpserver-optsobject

At that document, some title use #, :, srv, and I can't understand what they mean.

Another question is, does anybody know about tutorial or guidance post of socket.io? The official document has only few examples and the explanation is insufficient to me.

Thanks.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
casamia
  • 619
  • 1
  • 10
  • 19

2 Answers2

0
  • Server() takes an http#Server, and the variable name is srv.
  • It also takes an Object called opts (e.g., options).

It does not return anything. By contrast, look at serveClient a few lines lower:

Server#serveClient(v:Boolean):Server

The trailing :Server means it returns a Server.

(An http.Server is an event emitter class, covered in the NodeJS docs.)

Search the web for socket.io tutorials; requesting off-site resources is OT for SO.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • Oh, I'm almost understanding. By the way, do there any special reason to use "#", rather than "." ? That's why i'm confused. – casamia Mar 17 '15 at 02:07
  • @casamia Because that's what people use? It's used in Java and Ruby as well, e.g., http://stackoverflow.com/q/2587896/438992, http://stackoverflow.com/q/736120/438992, etc. – Dave Newton Mar 17 '15 at 02:10
0

I've spent the last 12 weeks building a production app using socket.io, and I feel you with the documentation frustrations.

Dave's answer is exactly what I was going to tell you regarding the actual command.

Regarding decyphering the documentation:

  • the colon ( : ) is used to specify the type of parameter being accepted.
  • hashtag ( # ) seems to represent properties of a particular object.
  • srv I'm not exactly sure, but I'm guessing it refers to the particular serve method you're opting to use.

If I'm correct about srv, why? The specific syntax you use to bind socket.io can vary depending on what other npm modules you're using. The documentation on socket.io shows that there's different ways to go about this.

theaccordance
  • 889
  • 5
  • 13