func (n *Network) sendEvent(ev events.Event) { var data struct { Type int Event events.Event } data.Type = ev.GetTypeID() data.Event = ev encoder := json.NewEncoder(n.conn) err := encoder.Encode(&data) if err != nil { if netErr, ok := err.(net.Error); ok && netErr.Temporary() { go func() { n.eventCh <- ev }() return } log.Println(err) n.Destroy() return } }
func (n *Network) handleEvent(ev events.Event) { if ev.HasDuplicate() { return } n.sendEvent(ev) }