Skip to content
This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
/ pstream Public archive

Length/header prefixed protobuf packet stream.

Notifications You must be signed in to change notification settings

paralin/pstream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Packet Stream

Simple protocol for streaming packets with a length prefix.

Usage

type Session struct {
	*pstream.Session
}

// RemoteEvent is defined as a protobuf message.

// readPump reads messages.
func (s *Session) readPump(ctx context.Context) {
	for {
		var msg RemoteEvent
		if err := s.Session.RecvMsg(&msg); err != nil {
			if err != io.EOF {
				le.WithError(err).Error("peer connection closed")
			}

			return
		}
        
        // handle msg
	}
}

subCtx, subCtxCancel := context.WithCancel(r.ctx)
pSess := pstream.NewSessionWithCompression(subCtx, subCtxCancel, stream)
sess := &Session{Session: pSess}
go sess.readPump(subCtx)

About

Length/header prefixed protobuf packet stream.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published