Example #1
0
func (s *Server) handlePacket(p packet.Packet, c *client.Client) {
	switch p.PacketType() {
	case packet.REQUEST:
		//send details packet
	case packet.ACK:
		//start streaming
	case packet.CLOSE:
		s.CloseConn(c)
	case packet.PING:
		s.SendPacket(packet.NewPongPacket(0), c)
	case packet.PONG:
		//do nothing, client keep alive
	default:
		logger.Printf("Invalid packet with type: %d", p.PacketType())
	}
}
Example #2
0
func (c *Client) handlePacket(p packet.Packet) {
	switch p.PacketType() {
	case packet.DETAILS:
		//handle stream details
	case packet.STREAM:
		//handle streaming
	case packet.CLOSE:
		//close client
	case packet.PING:
		c.SendPacket(packet.NewPongPacket(0))
	case packet.PONG:
		//handle server last seen time
	default:
		logger.Printf("Invalid packet type: %d", p.PacketType())
	}
}