-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsocketio.go
executable file
·47 lines (39 loc) · 1.12 KB
/
socketio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package aimbotio
import (
"log"
"time"
"github.com/graarh/golang-socketio"
"github.com/graarh/golang-socketio/transport"
)
const delay = 2
type connection struct {
port int
name string
client *gosocketio.Client
}
func connect(connection *connection) {
var err error
connection.client, err = gosocketio.Dial(
gosocketio.GetUrl("localhost", connection.port, false),
transport.GetDefaultWebsocketTransport())
if err != nil {
log.Printf("%s Server (*%d) : Connection Error", connection.name, connection.port)
log.Fatal(err)
} else {
log.Printf("%s Server (*%d) : Connection Established", connection.name, connection.port)
}
time.Sleep(delay * time.Microsecond)
}
func emit(connection *connection, eventName string, data string) {
err := connection.client.Emit(eventName, data)
if err != nil {
log.Fatal(err)
} else {
log.Printf("%s Server (*%d) : Data Transmitted : %s", connection.name, connection.port, data)
}
time.Sleep(delay * time.Microsecond)
}
func disconnect(connection *connection) {
connection.client.Close()
log.Printf("%s Server (*%d) : Disconnected", connection.name, connection.port)
}