evio icon indicating copy to clipboard operation
evio copied to clipboard

how to send data to other conn?

Open zzxap opened this issue 11 months ago • 0 comments

events.Data = func(c evio.Conn, in []byte) (out []byte, action evio.Action) { fmt.Println("events.Data ") if in == nil { //how to know is close action? fmt.Println("in is nil Closed") action = evio.Close return

	} else {
                 // how to send data????????
		fmt.Println("dataToSend ")
		//dataToSend := c.Context().([]byte)
		//if dataToSend != nil {
		//	out = append(out, dataToSend...)
		//	return
		//}
	}

	fmt.Println("ReceiveData ")
	fmt.Println(string(in))
	toConn, _ := getconnByJsonData(c, in)
	if toConn != nil {
		fmt.Println("send Data ")
		toConn.SetContext(in)
		toConn.Wake()
	}

	return
} 

I save conn in a map userid->conn and get it by getconnByJsonData(c, in) how to send data to other conn?

zzxap avatar Jul 31 '23 01:07 zzxap