// Start performs the initial handshake and starts receiving streams of data. This is used for servers only. For clients, use StartPlayback().
Start performs the initial handshake and starts receiving streams of data. This is used for servers only. For clients, use StartPlayback().
// Start performs the initial handshake and starts receiving streams of data . This is used for servers only . For clients use StartPlayback () .
func (session *Session) Start() error {
	err := session.messageManager.Initialize()
	if err != nil {
		return err
	}
	defer func() {
		if session.isPlayer {
			if config.Debug {
				fmt.Println("session: destroying subscriber")
			}
			session.broadcaster.DestroySubscriber(session.streamKey, session.sessionID)
		}
		if session.isPublisher {
			if config.Debug {
				fmt.Println("session: destroying publisher")
			}
			session.broadcaster.BroadcastEndOfStream(session.streamKey)
			session.broadcaster.DestroyPublisher(session.streamKey)
		}
	}()
	if config.Debug {
		fmt.Println("Handshake completed successfully")
	}
	for {
		if session.active {
			if err = session.messageManager.nextMessage(); err != nil {
				return err
			}
		} else {
			return nil
		}
	}
}
func ( session * Session ) Start ( ) error { err := session . messageManager . Initialize ( ) if err != nil { return err } defer func ( ) { if session . isPlayer { if config . Debug { fmt . Println ( " " ) } session . broadcaster . DestroySubscriber ( session . streamKey , session . sessionID ) } if session . isPublisher { if config . Debug { fmt . Println ( " " ) } session . broadcaster . BroadcastEndOfStream ( session . streamKey ) session . broadcaster . DestroyPublisher ( session . streamKey ) } } ( ) if config . Debug { fmt . Println ( " " ) } for { if session . active { if err = session . messageManager . nextMessage ( ) ; err != nil { return err } } else { return nil } } }
Start performs the initial handshake and starts receiving streams of data.
Start performs the initial handshake and starts receiving streams of data .
// Perform handshake // Remove the session from the context // Broadcast end of stream // After handshake, start reading chunks