Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rodkranz/go.io
Socket.io Go
https://github.com/rodkranz/go.io
Last synced: 5 days ago
JSON representation
Socket.io Go
- Host: GitHub
- URL: https://github.com/rodkranz/go.io
- Owner: rodkranz
- Created: 2016-11-09T18:51:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-09T18:57:07.000Z (about 8 years ago)
- Last Synced: 2024-11-07T22:42:28.555Z (about 2 months ago)
- Language: HTML
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Socket.io Go
#### Start Server
$ go run main.go
> you can access by url: `http://localhost:5000/`
---
#### Activate WebHook$ http://localhost:5000/webhook?act=Chat&txt=Lorem
> The `act` (activation) and `txt` (text) are mandatory fields
---
#### Frontend Javascript
(function () {
'use strict';var socket = io();
var act = 'Chat'; // activation
// Receive data from socket and call `receiveData`
socket.on(act, receiveData);/**
* ReceiveData
* @param data
*/
function receiveData(data) {
var msg = message(data);
$('#messages').append(msg);
animation(msg);
}/**
* Create element li empty with display none
* @param data
* @returns {*|jQuery}
*/
function message(data) {
return $('
.css({display: "none"})
.text(data);
}
/**
* Start animation
* @param elm
* @param callback
*/
function animation(elm, callback) {
var self = $(elm);
self.fadeIn(700, function () {
setTimeout(function() {
self.fadeOut(700, callback)
}, 5000);
});
}
})();
---