Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

ddddddO/sip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Session Initiation Protocol

Install

go get github.com/ddddddO/sip

Usage

Server

import (
	"io"
	"log"
	"os"

	"github.com/ddddddO/sip"
)

func XXXXX() {
	enableServer := true
	enableClient := false
	laddr := "localhost:5060"
	clientCnt := 1
	availableSessions := sip.GetAvailableSessions(sip.NewConfig(
		enableServer, laddr, clientCnt, // for Server setup
		enableClient, nil, // for Client setup
	))

	for i := range availableSessions {
		func(ss *sip.Session) {
			// send to client
			if _, err := ss.Write([]byte("Hello! by server..\n")); err != nil {
				panic(err)
			}

			// recieve from client
			io.Copy(os.Stdout, ss)
		}(availableSessions[i])
	}
}

Client

import (
	"io"
	"log"
	"os"

	"github.com/ddddddO/sip"
)

func YYYYY() {
	enableServer := false
	enableClient := true
	raddrs := []string{"localhost:5060"}
	availableSessions := sip.GetAvailableSessions(sip.NewConfig(
		enableServer, "", 0, // for Server setup
		enableClient, raddrs, // for Client setup
	))

	for i := range availableSessions {
		func(ss *sip.Session) {
			// send to server
			if _, err := ss.Write([]byte("Hey! by client!\n")); err != nil {
				panic(err)
			}

			// recieve from server
			io.Copy(os.Stdout, ss)
		}(availableSessions[i])
	}
}

Examples

Pattern in which the roles of server and client are separated.

github.com/ddddddO/sip/example/pattern1

Pattern in which the roles of server and client are integrated.

github.com/ddddddO/sip/example/pattern2

Reference

About

[WIP] Session Initiation Protocol

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages