Socket.io extension

Source: Internet
Author: User

The project just used instant messaging, so I researched websocket technology and discovered a solution that could be used simultaneously on the web, [Android], [IOS], and that's socketio. The implementation of the principle of what does not introduce, directly affixed to the iOS project may use some resources.

The first is the official website: http://socket.io/This people will not be unfamiliar with it ~ ~

1, the official recommended Android project: Http://socket.io/blog/native-socket-io-and-android/

The corresponding address on GitHub is: Https://github.com/nkzawa/socket.io-android-chat

2, the official recommended Ios--swift project: http://socket.io/blog/socket-io-on-ios/

The corresponding address on GitHub is: Https://github.com/socketio/socket.io-client-swift

In addition, if you need the OC version, you can refer to this: Socket.io v0.7.2-0.9.x for IOS and OS x HTTPS://GITHUB.COM/PKYECK/SOCKET.IO-OBJC

3. The official recommended C + + project: http://socket.io/blog/socket-io-cpp/

The corresponding address on GitHub is: https://github.com/socketio/socket.io-client-cpp

There's also an anonymous chat room for you to test with: http://chat.socket.io/
About the configuration of those pits and the principles of websocket development

Because the iOS website only introduce swift code, if need to use to OC version need to download unofficial version on GitHub, in the background with various toss, finally found unofficial OC version configuration incompatible with the background of the demand, re-changed the official version of Swift, Bridge the Swift file in the OC project.

Background using workman Open-source push mechanism, the message immediately sent to the client, the principle and Webviewjavascriptbridge similar, it is understood to use this mechanism, but the framework may be different, because the background is open source server, the development of the difficulty is not big, It's just a matter of time cost;

When using the key value, it needs to be configured in the background.

This refers to sending a message according to the "group chat" key value to point to the corresponding method of the server, passing the data past

socket.on ( "group chat") {(DataArray, Socketack), void invar Messagedictionary = [string: anyobject] () print ( "group chat DataArray =%@", DataArray) let messagedict = Dataarray[0];messagedictionary[  "username"] = Messagedict[ "username"]messagedictionary[ "message"] = Messagedict[ "message"] Print ( "Messagedictionary =%@", messagedictionary) Completionhandler (messageinfo: messagedictionary)}               

The following is the notification of the monitoring server according to the "disconnect" key value to call the corresponding method to be processed

In the configuration of the use of the process, using a unified form of callback block form can, the method is very concise, there are questions welcome message




Reference Link: 0.http://www.infoq.com/cn/news/2015/01/socket-io-websocket1.http://www.jianshu.com/p/a7757baf3bad
2.http://www.imooc.com/article/34533.http://www.jianshu.com/p/f643d74e6732

Socket.io extension

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.