예제 #1
0
파일: network.go 프로젝트: Emudofus/gofus
func server_conn_rcv(ctx *context, conn net.Conn) {
	client := NewNetClient(conn, <-ctx.nextClientId, <-ctx.nextClientTicket)
	defer server_conn_close(ctx, client)

	ctx.events <- event{client: client, login: true}

	buf := shared.Bufferize(conn, []byte(input_msg_delimiter), chunk_len)
	for ctx.running && client.Alive() {
		if data, ok := <-buf; ok {
			ctx.tasks <- task{client, data}
		} else {
			break
		}
	}
}
예제 #2
0
파일: network.go 프로젝트: Emudofus/gofus
func server_conn_rcv(ctx *context, conn net.Conn) {
	client := new_net_client(conn, <-ctx.nextClientId)
	defer server_conn_close(ctx, client)

	ctx.events <- event{client, true}

	buf := shared.Bufferize(conn, []byte(input_msg_delimiter), chunk_len)
	for ctx.running && client.alive {
		if data, ok := <-buf; ok {
			log.Printf("[frontend-net-client-%04d] RCV(%03d) %s", client.Id(), len(data), data)
			if msg, ok := msg.New(string(data[:2])); ok {
				in := bytes.NewReader(data)
				msg.Deserialize(in)

				ctx.tasks <- task{client, msg}
			} else {
				log.Printf("[frontend-net-client-%04d] unknown opcode %s", client.Id(), data[:2])
			}
		} else {
			break
		}
	}
}