mirror of
				https://gitlab.com/comunic/ComunicRTCProxy
				synced 2025-11-04 04:04:19 +00:00 
			
		
		
		
	Can specify a time before auto-restart
This commit is contained in:
		@@ -16,6 +16,11 @@ type Config struct {
 | 
			
		||||
	Port     int
 | 
			
		||||
	Path     string
 | 
			
		||||
	Token    string
 | 
			
		||||
 | 
			
		||||
	// Amount of time to wait before automatically
 | 
			
		||||
	//quitting the application when the websocket
 | 
			
		||||
	// connection was interrupted
 | 
			
		||||
	Restart int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get the URL associated with the configuration
 | 
			
		||||
 
 | 
			
		||||
@@ -6,4 +6,9 @@ secure: false
 | 
			
		||||
hostname: 127.0.0.1
 | 
			
		||||
port: 3000
 | 
			
		||||
path: /rtc_proxy/ws
 | 
			
		||||
token: SecretToken
 | 
			
		||||
token: SecretToken
 | 
			
		||||
 | 
			
		||||
# Number of seconds to wait before automatically 
 | 
			
		||||
# closing the proxy (if WebSocket connection was
 | 
			
		||||
# interrupted)
 | 
			
		||||
restart: 0
 | 
			
		||||
							
								
								
									
										10
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								main.go
									
									
									
									
									
								
							@@ -2,7 +2,9 @@ package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"os"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
@@ -17,6 +19,14 @@ func main() {
 | 
			
		||||
	// First, load the config
 | 
			
		||||
	conf := loadConfig(os.Args[1])
 | 
			
		||||
 | 
			
		||||
	/// Avoid to quick restart loop
 | 
			
		||||
	defer timeBeforeQuit(&conf)
 | 
			
		||||
 | 
			
		||||
	// Then connect to websocket
 | 
			
		||||
	openWs(&conf)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func timeBeforeQuit(c *Config) {
 | 
			
		||||
	log.Printf("Waiting %d seconds before quitting...", c.Restart)
 | 
			
		||||
	time.Sleep(time.Second * time.Duration(c.Restart))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								relay.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								relay.go
									
									
									
									
									
								
							@@ -388,6 +388,7 @@ func newCall(mainOffer receivedSignal, r *activeRelay) {
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	// Enter messags loop
 | 
			
		||||
	for {
 | 
			
		||||
 | 
			
		||||
		// Receive new channels
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user