mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-14 12:00:05 +00:00
CPunch
c0ba365cf5
- each CNPeer is given a unique chan *protocol.Event to pass events to the service.handleEvents() loop. this is now passed to CNPeer.Handler() as opposed to NewCNPeer(). - service has basically been rewritten. handleEvents() main loop uses reflect.SelectCase() now to handle all of the eRecv channels for each peer - new protocol Event type: EVENT_CLIENT_CONNECT - Added service_test.go; blackbox-styled testing like the others. TestService() starts a service and spins up a bunch of dummy peers and verifies that each packet sent causes the corresponding packet handler to be called.
17 lines
203 B
Go
17 lines
203 B
Go
package protocol
|
|
|
|
import "bytes"
|
|
|
|
const (
|
|
EVENT_CLIENT_DISCONNECT = iota
|
|
EVENT_CLIENT_CONNECT
|
|
EVENT_CLIENT_PACKET
|
|
)
|
|
|
|
type Event struct {
|
|
Type int
|
|
Peer *CNPeer
|
|
Pkt *bytes.Buffer
|
|
PktID uint32
|
|
}
|