예제 #1
0
func (rsp *flowAckResponse) WriteTo(w *xio.PacketWriter) error {
	if err := w.Write7BitValue64(rsp.fid); err != nil {
		return err
	}
	if err := w.Write7BitValue64(rsp.cnt); err != nil {
		return err
	}
	if err := storeFlowAck(rsp.ack, w); err != nil {
		return err
	}
	return nil
}
예제 #2
0
func (rsp *flowResponse) WriteTo(w *xio.PacketWriter) error {
	flags := rsp.f.flags
	if rsp.header {
		flags |= flagsHeader
	}
	if err := w.Write8(flags); err != nil {
		return err
	}
	if rsp.header {
		if err := w.Write7BitValue64(rsp.fw.fid); err != nil {
			return err
		}
		if err := w.Write7BitValue64(rsp.f.stage); err != nil {
			return err
		}
		if err := w.Write7BitValue64(rsp.f.delta); err != nil {
			return err
		}
		if len(rsp.fw.signature) != 0 {
			if err := w.WriteString8(rsp.fw.signature); err != nil {
				return err
			}
			if rsp.fr.fid != 0 {
				more := 1
				if add, err := xio.SizeOf7BitValue64(rsp.fr.fid); err != nil {
					return err
				} else {
					more += add
				}
				if err := w.Write7BitValue64(uint64(more)); err != nil {
					return err
				}
				if err := w.Write8(0x0a); err != nil {
					return err
				}
				if err := w.Write7BitValue64(rsp.fr.fid); err != nil {
					return err
				}
			}
		}
		if err := w.Write8(0); err != nil {
			return err
		}
	}
	if err := w.WriteBytes(rsp.f.data); err != nil {
		return err
	}
	return nil
}
예제 #3
0
func (rsp *assignResponse) WriteTo(w *xio.PacketWriter) error {
	if err := w.Write32(rsp.xid); err != nil {
		return errors.New("assign.write xid")
	}
	if err := w.Write7BitValue64(uint64(len(rsp.responder))); err != nil {
		return errors.New("assign.write responder size")
	}
	if err := w.WriteBytes(rsp.responder); err != nil {
		return errors.New("assign.write responder")
	}
	if err := w.Write8(0x58); err != nil {
		return errors.New("assign.write mode")
	}
	return nil
}
예제 #4
0
파일: flowack.go 프로젝트: edgarcai/xserver
func storeFlowAck(ack *flowAck, w *xio.PacketWriter) error {
	if err := w.Write7BitValue64(ack.stage); err != nil {
		return err
	} else {
		stage := ack.stage
		for e := ack.conts.Front(); e != nil; e = e.Next() {
			r := e.Value.(*flowAckRange)
			if err := w.Write7BitValue64(r.beg - stage - 2); err != nil {
				return err
			}
			if err := w.Write7BitValue64(r.end - r.beg); err != nil {
				return err
			}
			stage = r.end
		}
		return nil
	}
}