mirror of
https://github.com/PretendoNetwork/nex-go.git
synced 2025-04-02 11:02:14 -04:00
Every SocketConnection had a map of *PRUDPConnection, which was never actually inserted into anywhere, so the intended function of tracking what OS sockets have which PRUDP streams was not being done. Remove it as dead code. If the rest of the connection tracking is going to be implemented, this commit can be reverted. Since the SocketConnection no longer has long-lived state in it, also remove the map on PRUDPServer and just create it as a simple data structure when needed. The connection close handling of the websocket server had to be rewritten - the old code would never do anything due to the empty maps, so this can't be *worse* than nothing :)
24 lines
711 B
Go
24 lines
711 B
Go
package nex
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/lxzan/gws"
|
|
)
|
|
|
|
// SocketConnection represents a single open socket.
|
|
// A single socket may have many PRUDP connections open on it.
|
|
type SocketConnection struct {
|
|
Server *PRUDPServer // * PRUDP server the socket is connected to
|
|
Address net.Addr // * Sockets address
|
|
WebSocketConnection *gws.Conn // * Only used in PRUDPLite
|
|
}
|
|
|
|
// NewSocketConnection creates a new SocketConnection
|
|
func NewSocketConnection(server *PRUDPServer, address net.Addr, webSocketConnection *gws.Conn) *SocketConnection {
|
|
return &SocketConnection{
|
|
Server: server,
|
|
Address: address,
|
|
WebSocketConnection: webSocketConnection,
|
|
}
|
|
}
|