示例#1
0
func listen(name string, pipe *common.PeerPipe) (common.Packet, error) {

	reqch := pipe.ReceiveChannel()
	req, ok := <-reqch
	if !ok {
		return nil, common.NewError(common.SERVER_ERROR, "SyncProxy.listen(): channel closed. Terminate")
	}

	if req.Name() != name {
		return nil, common.NewError(common.PROTOCOL_ERROR,
			"SyncProxy.listen(): Expect message "+name+", Receive message "+req.Name())
	}

	return req, nil
}