Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
Archivo: recover.go Proyecto: 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))
	}
}