Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: StreamServer & PacketServer #38

Merged
merged 6 commits into from
Apr 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Imp: new udp session
  • Loading branch information
AlexStocks committed Apr 24, 2020
commit d6fb33625c2bdbbc4a16b7996e3b45476ae5915d
24 changes: 16 additions & 8 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,23 @@ func (s *server) runTcpEventLoop(newSession NewSessionCallback) {
}

func (s *server) runUDPEventLoop(newSession NewSessionCallback) {
var (
ss Session
)
s.wg.Add(1)
go func() {
defer s.wg.Done()
var (
err error
conn *net.UDPConn
ss Session
)

ss = newUDPSession(s.pktListener.(*net.UDPConn), s)
if err := newSession(ss); err != nil {
panic(err.Error())
}
ss.(*session).run()
conn = s.pktListener.(*net.UDPConn)
ss = newUDPSession(conn, s)
if err = newSession(ss); err != nil {
conn.Close()
panic(err.Error())
}
ss.(*session).run()
}()
}

type wsHandler struct {
Expand Down