Skip to content

Commit bbc29a9

Browse files
committed
🎨 Rename module
1 parent 9cd2944 commit bbc29a9

File tree

10 files changed

+111
-68
lines changed

10 files changed

+111
-68
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Examples directory contains simple client and server.
99

1010
### Installation
1111

12-
go get github.com/graarh/golang-socketio
12+
go get github.com/JulianKropp/golang-socketio
1313

1414
### Simple server usage
1515

‎_examples/client.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package main
22

33
import (
4-
"github.com/graarh/golang-socketio"
5-
"github.com/graarh/golang-socketio/transport"
64
"log"
75
"runtime"
86
"time"
7+
8+
"github.com/JulianKropp/golang-socketio/transport"
99
)
1010

1111
type Channel struct {

‎_examples/server.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package main
22

33
import (
4-
"github.com/graarh/golang-socketio"
5-
"github.com/graarh/golang-socketio/transport"
64
"log"
75
"net/http"
86
"time"
7+
8+
"github.com/JulianKropp/golang-socketio/transport"
99
)
1010

1111
type Channel struct {

‎client.go‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
package gosocketio
22

33
import (
4-
"github.com/graarh/golang-socketio/transport"
54
"strconv"
5+
6+
"github.com/JulianKropp/golang-socketio/transport"
67
)
78

89
const (
9-
webSocketProtocol = "ws://"
10+
webSocketProtocol = "ws://"
1011
webSocketSecureProtocol = "wss://"
11-
socketioUrl = "/socket.io/?EIO=3&transport=websocket"
12+
socketioUrl = "/socket.io/?EIO=3&transport=websocket"
1213
)
1314

14-
/**
15+
/*
16+
*
1517
Socket.io client representation
1618
*/
1719
type Client struct {
1820
methods
1921
Channel
2022
}
2123

22-
/**
24+
/*
25+
*
2326
Get ws/wss url by host and port
24-
*/
27+
*/
2528
func GetUrl(host string, port int, secure bool) string {
2629
var prefix string
2730
if secure {
@@ -32,22 +35,23 @@ func GetUrl(host string, port int, secure bool) string {
3235
return prefix + host + ":" + strconv.Itoa(port) + socketioUrl
3336
}
3437

35-
36-
func NewClient() (*Client) {
38+
func NewClient() *Client {
3739
c := &Client{}
3840
c.initChannel()
3941
c.initMethods()
4042
return c
4143
}
42-
/**
44+
45+
/*
46+
*
4347
connect to host and initialise socket.io protocol
4448
4549
The correct ws protocol url example:
4650
ws://myserver.com/socket.io/?EIO=3&transport=websocket
4751
4852
You can use GetUrlByHost for generating correct url
4953
*/
50-
func (c *Client) Dial(url string, tr transport.Transport) (error) {
54+
func (c *Client) Dial(url string, tr transport.Transport) error {
5155
var err error
5256
c.conn, err = tr.Connect(url)
5357
if err != nil {
@@ -61,7 +65,8 @@ func (c *Client) Dial(url string, tr transport.Transport) (error) {
6165
return nil
6266
}
6367

64-
/**
68+
/*
69+
*
6570
Close client connection
6671
*/
6772
func (c *Client) Close() {

‎go.mod‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
module socketio
1+
module github.com/JulianKropp/golang-socketio
22

33
go 1.19
44

5-
require github.com/graarh/golang-socketio v0.0.0-20170510162725-2c44953b9b5f
6-
75
require github.com/gorilla/websocket v1.5.0

‎go.sum‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
22
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
3-
github.com/graarh/golang-socketio v0.0.0-20170510162725-2c44953b9b5f h1:utzdm9zUvVWGRtIpkdE4+36n+Gv60kNb7mFvgGxLElY=
4-
github.com/graarh/golang-socketio v0.0.0-20170510162725-2c44953b9b5f/go.mod h1:8gudiNCFh3ZfvInknmoXzPeV17FSH+X2J5k2cUPIwnA=

‎handler.go‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package gosocketio
22

33
import (
44
"encoding/json"
5-
"github.com/graarh/golang-socketio/protocol"
6-
"sync"
75
"reflect"
6+
"sync"
7+
8+
"github.com/JulianKropp/golang-socketio/protocol"
89
)
910

1011
const (
@@ -13,12 +14,14 @@ const (
1314
OnError = "error"
1415
)
1516

16-
/**
17+
/*
18+
*
1719
System handler function for internal event processing
1820
*/
1921
type systemHandler func(c *Channel)
2022

21-
/**
23+
/*
24+
*
2225
Contains maps of message processing functions
2326
*/
2427
type methods struct {
@@ -29,14 +32,16 @@ type methods struct {
2932
onDisconnection systemHandler
3033
}
3134

32-
/**
35+
/*
36+
*
3337
create messageHandlers map
3438
*/
3539
func (m *methods) initMethods() {
3640
m.messageHandlers = make(map[string]*caller)
3741
}
3842

39-
/**
43+
/*
44+
*
4045
Add message processing function, and bind it to given method
4146
*/
4247
func (m *methods) On(method string, f interface{}) error {
@@ -52,7 +57,8 @@ func (m *methods) On(method string, f interface{}) error {
5257
return nil
5358
}
5459

55-
/**
60+
/*
61+
*
5662
Find message processing function associated with given method
5763
*/
5864
func (m *methods) findMethod(method string) (*caller, bool) {
@@ -79,7 +85,8 @@ func (m *methods) callLoopEvent(c *Channel, event string) {
7985
f.callFunc(c, &struct{}{})
8086
}
8187

82-
/**
88+
/*
89+
*
8390
Check incoming message
8491
On ack_resp - look for waiter
8592
On ack_req - look for processing function and send ack_resp

‎loop.go‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package gosocketio
33
import (
44
"encoding/json"
55
"errors"
6-
"github.com/graarh/golang-socketio/protocol"
7-
"github.com/graarh/golang-socketio/transport"
86
"net/http"
97
"sync"
108
"time"
9+
10+
"github.com/JulianKropp/golang-socketio/protocol"
11+
"github.com/JulianKropp/golang-socketio/transport"
1112
)
1213

1314
const (
@@ -18,7 +19,8 @@ var (
1819
ErrorWrongHeader = errors.New("Wrong header")
1920
)
2021

21-
/**
22+
/*
23+
*
2224
engine.io header to send or receive
2325
*/
2426
type Header struct {
@@ -28,7 +30,8 @@ type Header struct {
2830
PingTimeout int `json:"pingTimeout"`
2931
}
3032

31-
/**
33+
/*
34+
*
3235
socket.io connection handler
3336
3437
use IsAlive to check that handler is still working
@@ -53,7 +56,8 @@ type Channel struct {
5356
requestHeader http.Header
5457
}
5558

56-
/**
59+
/*
60+
*
5761
create channel, map, and set active
5862
*/
5963
func (c *Channel) initChannel() {
@@ -63,14 +67,16 @@ func (c *Channel) initChannel() {
6367
c.alive = true
6468
}
6569

66-
/**
70+
/*
71+
*
6772
Get id of current socket connection
6873
*/
6974
func (c *Channel) Id() string {
7075
return c.header.Sid
7176
}
7277

73-
/**
78+
/*
79+
*
7480
Checks that Channel is still alive
7581
*/
7682
func (c *Channel) IsAlive() bool {
@@ -80,7 +86,8 @@ func (c *Channel) IsAlive() bool {
8086
return c.alive
8187
}
8288

83-
/**
89+
/*
90+
*
8491
Close channel
8592
*/
8693
func closeChannel(c *Channel, m *methods, args ...interface{}) error {
@@ -110,7 +117,7 @@ func closeChannel(c *Channel, m *methods, args ...interface{}) error {
110117
return nil
111118
}
112119

113-
//incoming messages loop, puts incoming messages to In channel
120+
// incoming messages loop, puts incoming messages to In channel
114121
func inLoop(c *Channel, m *methods) error {
115122
for {
116123
pkg, err := c.conn.GetMessage()
@@ -149,7 +156,8 @@ func AmountOfOverflooded() int64 {
149156
return int64(len(overflooded))
150157
}
151158

152-
/**
159+
/*
160+
*
153161
outgoing messages loop, sends messages from channel to socket
154162
*/
155163
func outLoop(c *Channel, m *methods) error {
@@ -180,7 +188,8 @@ func outLoop(c *Channel, m *methods) error {
180188
return nil
181189
}
182190

183-
/**
191+
/*
192+
*
184193
Pinger sends ping messages for keeping connection alive
185194
*/
186195
func pinger(c *Channel) {

‎send.go‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ package gosocketio
33
import (
44
"encoding/json"
55
"errors"
6-
"github.com/graarh/golang-socketio/protocol"
76
"log"
87
"time"
8+
9+
"github.com/JulianKropp/golang-socketio/protocol"
910
)
1011

1112
var (
1213
ErrorSendTimeout = errors.New("Timeout")
1314
ErrorSocketOverflood = errors.New("Socket overflood")
1415
)
1516

16-
/**
17+
/*
18+
*
1719
Send message packet to socket
1820
*/
1921
func send(msg *protocol.Message, c *Channel, args interface{}) error {
@@ -47,7 +49,8 @@ func send(msg *protocol.Message, c *Channel, args interface{}) error {
4749
return nil
4850
}
4951

50-
/**
52+
/*
53+
*
5154
Create packet based on given data and send it
5255
*/
5356
func (c *Channel) Emit(method string, args interface{}) error {
@@ -59,7 +62,8 @@ func (c *Channel) Emit(method string, args interface{}) error {
5962
return send(msg, c, args)
6063
}
6164

62-
/**
65+
/*
66+
*
6367
Create ack packet based on given data and send it and receive response
6468
*/
6569
func (c *Channel) Ack(method string, args interface{}, timeout time.Duration) (string, error) {

0 commit comments

Comments
 (0)