예제 #1
0
파일: connection.go 프로젝트: gemrs/gem
func (c *Connection) Init(conn net.Conn, parentLogger log.Log) {
	c.ReadBuffer = encoding.NewBuffer()
	c.WriteBuffer = encoding.NewBuffer()
	c.Read = make(chan encoding.Decodable, 16)
	c.Write = make(chan encoding.Encodable, 16)
	c.DisconnectChan = make(chan bool)

	c.log = parentLogger.Child("connection", log.MapContext{"addr": conn.RemoteAddr().String()})
	c.conn = conn
}
예제 #2
0
파일: recover.go 프로젝트: gemrs/gem
// recover captures panics in the game client handler and prints a stack trace
func Recover(log log.Log) {
	if err := recover(); err != nil {
		if Unsafe {
			log.Notice("github.com/gemrs/gem/gem/safe: Unsafe mode enabled; not recovering")
			panic(err)
		}
		stack := make([]byte, 1024*10)
		runtime.Stack(stack, true)
		log.Error("Recovered from panic in game client handler: %v", err)
		log.Debug(string(stack))
	}
}