當前位置: 首頁>>代碼示例>>Golang>>正文


Golang xdr.NewReader函數代碼示例

本文整理匯總了Golang中github.com/calmh/syncthing/xdr.NewReader函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewReader函數的具體用法?Golang NewReader怎麽用?Golang NewReader使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewReader函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewConnection

func NewConnection(nodeID NodeID, reader io.Reader, writer io.Writer, receiver Model, name string) Connection {
	cr := &countingReader{Reader: reader}
	cw := &countingWriter{Writer: writer}

	rb := bufio.NewReader(cr)
	wb := bufio.NewWriterSize(cw, 65536)

	c := rawConnection{
		id:       nodeID,
		name:     name,
		receiver: nativeModel{receiver},
		state:    stateInitial,
		cr:       cr,
		xr:       xdr.NewReader(rb),
		cw:       cw,
		wb:       wb,
		xw:       xdr.NewWriter(wb),
		awaiting: make([]chan asyncResult, 0x1000),
		outbox:   make(chan []encodable),
		nextID:   make(chan int),
		closed:   make(chan struct{}),
	}

	go c.readerLoop()
	go c.writerLoop()
	go c.pingerLoop()
	go c.idGenerator()

	return wireFormatConnection{&c}
}
開發者ID:KayoticSully,項目名稱:syncthing,代碼行數:30,代碼來源:protocol.go

示例2: NewConnection

func NewConnection(nodeID string, reader io.Reader, writer io.Writer, receiver Model) Connection {
	cr := &countingReader{Reader: reader}
	cw := &countingWriter{Writer: writer}

	flrd := flate.NewReader(cr)
	flwr, err := flate.NewWriter(cw, flate.BestSpeed)
	if err != nil {
		panic(err)
	}
	wb := bufio.NewWriter(flwr)

	c := rawConnection{
		id:        nodeID,
		receiver:  nativeModel{receiver},
		reader:    flrd,
		cr:        cr,
		xr:        xdr.NewReader(flrd),
		writer:    flwr,
		cw:        cw,
		wb:        wb,
		xw:        xdr.NewWriter(wb),
		awaiting:  make([]chan asyncResult, 0x1000),
		indexSent: make(map[string]map[string][2]int64),
		outbox:    make(chan []encodable),
		nextID:    make(chan int),
		closed:    make(chan struct{}),
	}

	go c.readerLoop()
	go c.writerLoop()
	go c.pingerLoop()
	go c.idGenerator()

	return wireFormatConnection{&c}
}
開發者ID:Zypan,項目名稱:syncthing,代碼行數:35,代碼來源:protocol.go

示例3: NewConnection

func NewConnection(nodeID string, reader io.Reader, writer io.Writer, receiver Model, options map[string]string) *Connection {
	flrd := flate.NewReader(reader)
	flwr, err := flate.NewWriter(writer, flate.BestSpeed)
	if err != nil {
		panic(err)
	}

	c := Connection{
		id:        nodeID,
		receiver:  receiver,
		reader:    flrd,
		xr:        xdr.NewReader(flrd),
		writer:    flwr,
		xw:        xdr.NewWriter(flwr),
		awaiting:  make(map[int]chan asyncResult),
		indexSent: make(map[string]map[string][2]int64),
	}

	go c.readerLoop()
	go c.pingerLoop()

	if options != nil {
		c.myOptions = options
		go func() {
			c.Lock()
			header{0, c.nextID, messageTypeOptions}.encodeXDR(c.xw)
			var om OptionsMessage
			for k, v := range options {
				om.Options = append(om.Options, Option{k, v})
			}
			om.encodeXDR(c.xw)
			err := c.xw.Error()
			if err == nil {
				err = c.flush()
			}
			if err != nil {
				log.Println("Warning: Write error during initial handshake:", err)
			}
			c.nextID++
			c.Unlock()
		}()
	}

	return &c
}
開發者ID:ngpestelos,項目名稱:syncthing,代碼行數:45,代碼來源:protocol.go

示例4: UnmarshalXDR

func (o *IndexMessage) UnmarshalXDR(bs []byte) error {
	var br = bytes.NewReader(bs)
	var xr = xdr.NewReader(br)
	return o.decodeXDR(xr)
}
開發者ID:jjoergensen,項目名稱:syncthing,代碼行數:5,代碼來源:message_xdr.go

示例5: DecodeXDR

func (o *Option) DecodeXDR(r io.Reader) error {
	xr := xdr.NewReader(r)
	return o.decodeXDR(xr)
}
開發者ID:jjoergensen,項目名稱:syncthing,代碼行數:4,代碼來源:message_xdr.go

示例6: DecodeXDR

func (o *repeatReader) DecodeXDR(r io.Reader) error {
	xr := xdr.NewReader(r)
	return o.decodeXDR(xr)
}
開發者ID:BenKoerber,項目名稱:syncthing,代碼行數:4,代碼來源:bench_xdr_test.go

示例7: DecodeXDR

func (o *AnnounceV2) DecodeXDR(r io.Reader) error {
	xr := xdr.NewReader(r)
	return o.decodeXDR(xr)
}
開發者ID:nbrownus,項目名稱:syncthing,代碼行數:4,代碼來源:packets_xdr.go

示例8: DecodeXDR

func (o *versionList) DecodeXDR(r io.Reader) error {
	xr := xdr.NewReader(r)
	return o.decodeXDR(xr)
}
開發者ID:jjoergensen,項目名稱:syncthing,代碼行數:4,代碼來源:leveldb_xdr.go

示例9: DecodeXDR

func (o *TestStruct) DecodeXDR(r io.Reader) error {
	xr := xdr.NewReader(r)
	return o.decodeXDR(xr)
}
開發者ID:KayoticSully,項目名稱:syncthing,代碼行數:4,代碼來源:encdec_xdr_test.go

示例10: UnmarshalXDR

func (o *ClusterConfigMessage) UnmarshalXDR(bs []byte) error {
	var buf = bytes.NewBuffer(bs)
	var xr = xdr.NewReader(buf)
	return o.decodeXDR(xr)
}
開發者ID:nbrownus,項目名稱:syncthing,代碼行數:5,代碼來源:message_xdr.go

示例11: DecodeXDR

func (o *QueryV1) DecodeXDR(r io.Reader) error {
	xr := xdr.NewReader(r)
	return o.decodeXDR(xr)
}
開發者ID:ngpestelos,項目名稱:syncthing,代碼行數:4,代碼來源:packets_xdr.go

示例12: UnmarshalXDR

func (o *AnnounceV2) UnmarshalXDR(bs []byte) error {
	var buf = bytes.NewBuffer(bs)
	var xr = xdr.NewReader(buf)
	return o.decodeXDR(xr)
}
開發者ID:nbrownus,項目名稱:syncthing,代碼行數:5,代碼來源:packets_xdr.go

示例13: UnmarshalXDR

func (o *XDRBenchStruct) UnmarshalXDR(bs []byte) error {
	var br = bytes.NewReader(bs)
	var xr = xdr.NewReader(br)
	return o.decodeXDR(xr)
}
開發者ID:BenKoerber,項目名稱:syncthing,代碼行數:5,代碼來源:bench_xdr_test.go


注:本文中的github.com/calmh/syncthing/xdr.NewReader函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。