Skip to content

Commit

Permalink
♻️ refactor: updated codebase #14
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jan 5, 2024
1 parent 1e10c21 commit b4070b0
Show file tree
Hide file tree
Showing 44 changed files with 73 additions and 59 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ Asterisk in Golang provides a wide range of features, including call routing, re

With Asterisk in Golang, developers benefit from the strengths of both the Golang language and the Asterisk ecosystem, resulting in reliable and efficient VOIP solutions that meet the demands of modern communication systems.

### Requirement

The go version 1.20

### Installation

- Use a specific version (tag)

```bash
go get github.com/pnguyen215/[email protected]
```

- Latest version

```bash
go get -u github.com/pnguyen215/voipkit@latest
```

### Usage

- [Asterisk Manager Interface (AMI)](https://github.com/pnguyen215/gobase-voip-core/blob/master/docs/ami.md)
- [Asterisk Manager Interface (AMI)](https://github.com/pnguyen215/voipkit/blob/master/docs/ami.md)

### Github Action

Expand Down
28 changes: 12 additions & 16 deletions docs/ami.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Asterisk Manager Interface (AMI)

## Installation

```sh
go get -u github.com/pnguyen215/[email protected]
```

## Usage

1. Open connection to asterisk server
Expand All @@ -32,7 +26,7 @@ package main
import (
"log"

"github.com/pnguyen215/gobase-voip-core/pkg/ami"
"github.com/pnguyen215/voipkit/pkg/ami"
)

func NewClient() (*ami.AMI, error) {
Expand All @@ -41,7 +35,7 @@ func NewClient() (*ami.AMI, error) {
}

func main() {

client, err := NewClient()

if err != nil {
Expand All @@ -52,7 +46,7 @@ func main() {
```

2. Custom listen all events from asterisk
// note: using go func(){...}
// note: using go func(){...}

```Go
// AllEvents subscribes to any AMI message received from Asterisk server
Expand All @@ -75,8 +69,8 @@ import (
"log"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami"
"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewClient() (*ami.AMI, error) {
Expand Down Expand Up @@ -120,7 +114,7 @@ package main
import (
"log"

"github.com/pnguyen215/gobase-voip-core/pkg/ami"
"github.com/pnguyen215/voipkit/pkg/ami"
)

func NewClient() (*ami.AMI, error) {
Expand All @@ -146,6 +140,7 @@ func main() {
```

4. Listen events and get field from event by adding key-value you want to take value from that field

##### Example

```Go
Expand All @@ -154,7 +149,7 @@ package main
import (
"log"

"github.com/pnguyen215/gobase-voip-core/pkg/ami"
"github.com/pnguyen215/voipkit/pkg/ami"
)

func NewClient() (*ami.AMI, error) {
Expand Down Expand Up @@ -184,7 +179,8 @@ func main() {
```

5. Listen events and get field from event by adding key-value you want to take value from that field.
You can customize event by adding new callback function
You can customize event by adding new callback function

##### Example

```Go
Expand All @@ -193,7 +189,7 @@ package main
import (
"log"

"github.com/pnguyen215/gobase-voip-core/pkg/ami"
"github.com/pnguyen215/voipkit/pkg/ami"
)

func NewClient() (*ami.AMI, error) {
Expand Down Expand Up @@ -224,4 +220,4 @@ func main() {
})
}()
}
```
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pnguyen215/gobase-voip-core
module github.com/pnguyen215/voipkit

go 1.20

Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// NewAmi connect to Asterisk Server using net connection and try to login
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_ confbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// ConfbridgeList lists all users in a particular ConfBridge conference.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_ presence.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// PresenceState check presence state.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAction() *AMIAction {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// Agents lists agents and their status.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_agi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// AGI add an AGI command to execute by Async AGI.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_atxfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// Atxfer attended transfer.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// Bridge bridges two channels already in the PBX.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

type AMICallbackService interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_cdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAMICdr() *AMICdr {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewChannel() *AMIChannel {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_chanspy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAMIPayloadChanspy() *AMIPayloadChanspy {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_class.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ami

import (
"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

var chargingEvents *map[string]string = &map[string]string{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
"golang.org/x/exp/slices"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"
"time"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"log"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewCore() *AMICore {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_dahd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// DAHDIDialOffhook dials over DAHDI channel while offhook.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAMIPayloadDb() *AMIPayloadDb {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_dialplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAMIPayloadExtension() *AMIPayloadExtension {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

var overlapDictionaries *[]AMIEventDictionary = &[]AMIEventDictionary{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewEventListener() *AMIEvent {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// ExtensionStateList list the current known extension states.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_fax.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// FAXSession responds with a detailed description of a single FAX session.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"time"

"github.com/nyaruka/phonenumbers"
"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"

jsonI "github.com/json-iterator/go"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_iax.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// IAXnetstats show IAX channels network statistics.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_khomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAMIPayloadKhompSMS() *AMIPayloadKhompSMS {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ami
import (
"context"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

// MailboxCount checks Mailbox Message Count.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func NewAuth() *AMIAuth {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ami/ami_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"
"time"

"github.com/pnguyen215/gobase-voip-core/pkg/ami/config"
"github.com/pnguyen215/voipkit/pkg/ami/config"
)

func (c *AMICore) ExtensionStatesMap(ctx context.Context, guard *AMIExtensionGuard) (response []AMIExtensionStatus, err error) {
Expand Down
Loading

0 comments on commit b4070b0

Please sign in to comment.