You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example provided is an echo server - but what if i wanted to change it into a 'chat server' - that would send data from one client to all other connected clients than the one that sent the data ?
Am unsure how it should be structured correctly :
// Convert the IP:socket for populating TCPAddr value.
parts := bytes.Split([]byte(c.ipAddress), []byte(":"))
ipAddress := string(parts[0])
port, _ := strconv.Atoi(string(parts[1]))
// Create the request.
r := Request{
TCP: c.t,
TCPAddr: &net.TCPAddr{
IP: net.ParseIP(ipAddress),
Port: port,
Zone: c.t.tcpAddr.Zone,
},
IsIPv6: c.isIPv6,
ReadAt: c.lastAct,
Context: context.Background(),
Data: data,
Length: length,
}
// Process the request on this goroutine that is
// handling the socket connection.
c.t.ReqHandler.Process(&r)
Process() is where it calls the routine that in the end will send to that specific client - but if i instead looped through all clients that was not the sending client calling process on each of them something im not sure if that is the correct way ?
any ideas on how i would need to that the correct way ?
The text was updated successfully, but these errors were encountered:
The example provided is an echo server - but what if i wanted to change it into a 'chat server' - that would send data from one client to all other connected clients than the one that sent the data ?
Am unsure how it should be structured correctly :
Process() is where it calls the routine that in the end will send to that specific client - but if i instead looped through all clients that was not the sending client calling process on each of them something im not sure if that is the correct way ?
any ideas on how i would need to that the correct way ?
The text was updated successfully, but these errors were encountered: