Code Monkey home page Code Monkey logo

Comments (6)

beho1der avatar beho1der commented on July 19, 2024 1

Thank you very much for your help, translating the old project into golang, at the same time I'm studying the language

from amigo.

ivahaev avatar ivahaev commented on July 19, 2024

I think, need to add ConnectionID field to Settings and append it into every event. What do you think?

Also you can to do it in your code.

from amigo.

beho1der avatar beho1der commented on July 19, 2024

It would be great, but can enough append it into every event - Settings.Host, usually this is unique value.

from amigo.

ivahaev avatar ivahaev commented on July 19, 2024

You can do such this:

func DialBeginHandler(id int) func (map[string]string) {
	return func(e map[string]string) {
		// handling event and connection id
	}
}

func main() {
	for i, s := range conf.Asterisk {
		settings := &amigo.Settings{Username: s.Login, Password: s.Password, Host: s.IP, Port: s.Port}
		a := amigo.New(settings)
		a.Connect()

		a.RegisterHandler("DialBegin", DialBeginHandler(i))
	}
}

Now in handler you can handle additional info — connection id. You can pass host, port or any other necessary info.

from amigo.

ivahaev avatar ivahaev commented on July 19, 2024

I think, it's enough to solve you task and no need to update amigo.

from amigo.

beho1der avatar beho1der commented on July 19, 2024

YES, this is a great solution, add to the examples

from amigo.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.