mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
agent: Use GOOPS
GOOPS is Guile Object Oriented Programming System. It's easier to extend and break less the scenarios using GOOPS. e.g., a scenario published on Gitlab should work two weeks later. This is not the case right now and the goal of using GOOPS is to offer a stable API for the agent, while keeping it flexible. Change-Id: If6a038b6d8c371f8e74849749770f1dec8559b91
This commit is contained in:

committed by
Sébastien Blin

parent
cefe9ce86b
commit
ce1995d172
23
test/agent/examples/active-agent.scm
Normal file → Executable file
23
test/agent/examples/active-agent.scm
Normal file → Executable file
@ -1,3 +1,6 @@
|
||||
#!/usr/bin/env -S ./agent.exe -s
|
||||
!#
|
||||
|
||||
;;; This is an example of an active agent.
|
||||
;;;
|
||||
;;; The active agent ensure that an account is created and then call its peer
|
||||
@ -6,7 +9,7 @@
|
||||
;;; We import here Jami's primitives.
|
||||
(use-modules
|
||||
(ice-9 threads)
|
||||
((agent) #:prefix agent:)
|
||||
(agent)
|
||||
((jami account) #:prefix account:)
|
||||
((jami signal) #:prefix jami:)
|
||||
((jami call) #:prefix call:)
|
||||
@ -45,28 +48,24 @@ hang up after MEDIA-FLOW seconds and #t is returned.
|
||||
(set! continue #f)
|
||||
success))))
|
||||
|
||||
;;; This ensure you have an account created for the agent.
|
||||
(agent:ensure-account)
|
||||
(define peer "FIXME")
|
||||
|
||||
;;; Change FIXME for the peer id you want to contact. You can also change the
|
||||
;;; value of media-flow and grace-period.
|
||||
(let loop ([account (agent:account-id)]
|
||||
[peer "FIXME"]
|
||||
(define agent (make-agent "bfbfbfbfbfbfbfbf"))
|
||||
|
||||
(make-friend agent peer)
|
||||
|
||||
(let loop ([account (account-id agent)]
|
||||
[media-flow 7]
|
||||
[grace-period 30])
|
||||
|
||||
;; Calling our PEER.
|
||||
(make-a-call account peer #:media-flow media-flow)
|
||||
|
||||
;; Disabling our account for GRACE-PERIOD.
|
||||
(jami:info "Disabling account")
|
||||
(account:send-register account #f)
|
||||
(sleep grace-period)
|
||||
|
||||
;; Renabling our account and wait GRACE-PERIOD.
|
||||
(jami:info "Enabling account")
|
||||
(account:send-register account #t)
|
||||
(sleep grace-period)
|
||||
|
||||
;; Loop again.
|
||||
(loop account peer media-flow grace-period))
|
||||
(loop account media-flow grace-period))
|
||||
|
1
test/agent/examples/agent.scm
Symbolic link
1
test/agent/examples/agent.scm
Symbolic link
@ -0,0 +1 @@
|
||||
../agent.scm
|
1
test/agent/examples/jami
Symbolic link
1
test/agent/examples/jami
Symbolic link
@ -0,0 +1 @@
|
||||
../jami
|
40
test/agent/examples/passive-agent.scm
Normal file → Executable file
40
test/agent/examples/passive-agent.scm
Normal file → Executable file
@ -1,22 +1,46 @@
|
||||
#!/usr/bin/env -S ./agent.exe -s
|
||||
!#
|
||||
|
||||
;;; This is an example of a passive agent.
|
||||
;;;
|
||||
;;; The passive agent ensure that an account is created and then wait for
|
||||
;;; incomming call of any peer.
|
||||
;;; The passive agent ensure that an account is created and accept all trust
|
||||
;;; requests and incoming calls.
|
||||
|
||||
(use-modules ((agent) #:prefix agent:)
|
||||
|
||||
(use-modules (agent)
|
||||
((jami account) #:prefix account:)
|
||||
((jami signal) #:prefix jami:)
|
||||
((jami call) #:prefix call:)
|
||||
((jami logger) #:prefix jami:))
|
||||
|
||||
(agent:ensure-account)
|
||||
(define this-agent (make-agent "afafafafafafafaf"))
|
||||
|
||||
(jami:info "Agent peer-id: ~a" (agent:peer-id))
|
||||
|
||||
(let ((account (agent:account-id)))
|
||||
(let ([account (account-id this-agent)])
|
||||
;; Accept all incoming calls with media.
|
||||
(jami:on-signal 'incoming-call/media
|
||||
(lambda (account-id call-id peer media-lst)
|
||||
(when (string= account-id account)
|
||||
(jami:info "Incoming [call:~a] with media ~a from peer ~a~%"
|
||||
call-id media-lst peer)
|
||||
(call:accept account-id call-id media-lst))
|
||||
#t))
|
||||
;; Accept all incoming calls.
|
||||
(jami:on-signal 'incoming-call
|
||||
(lambda (account-id call-id peer)
|
||||
(when (string= account-id account)
|
||||
(jami:info "Incoming [call:~a] from peer ~a~%" call-id peer)
|
||||
(call:accept call-id media-lst))
|
||||
(call:accept account-id call-id))
|
||||
#t))
|
||||
|
||||
;;; Accept all trust requests.
|
||||
(jami:on-signal 'incoming-trust-request
|
||||
(lambda (account-id conversation-id peer-id payload received)
|
||||
(when (string= account-id account)
|
||||
(jami:info "accepting trust request: ~a ~a" account-id peer-id)
|
||||
(account:accept-trust-request account-id peer-id))
|
||||
#t)))
|
||||
|
||||
|
||||
(jami:info "~a" this-agent)
|
||||
|
||||
(while #t (pause))
|
||||
|
Reference in New Issue
Block a user