Wednesday, May 6, 2015

Working more with NodeJS/SocketIO (5/5)

Today I started on one of my other projects and integrating Socket.io into it. I now have a go-to Socket.io script, as seen below.

As you can see, using the NodeJS modules http, express, and socket.io, a server is created. I then went and implemented this into my Android app like so:


And just like that (granted the Android device has an internet connection), the socket works! You can now use this as a server to send and receive data to one or multiple devices. I decided to change the event for each device, so the event is sent like 'socket.emit('deviceEvent ' + deviceId, informationHere)'. That way, the server can talk to individual Android devices. The Android code is as follows:

1 comment:

  1. Cool! I'm glad to see you doing more Android work, actually. Since with one month to go, I need to give you a grade for Computer Science II, and aside from the UMD programming contest you have only been very tangentially relating the CSII curriculum this quarter.

    I'm thinking I would like you to take the last eIMACs test (number 26 on Android development) as your final exam. Would that work? Let's talk in class today.

    ReplyDelete