Yate Community Forum

General Category => Yate users hangout place => Topic started by: smbakhtiar on March 12, 2013, 09:45:48 AM

Title: create user from database and making call using that user with defined duration
Post by: smbakhtiar on March 12, 2013, 09:45:48 AM
Hi All,

I want to configure user from database and the using that user i have to call on a another user and the user have a call expire time.After a duration of call the call will be disconnected automatically.Here is the design what i making of this.

1.using SIP protocol
2.Mysql Database


Bakhtiar
Title: Re: create user from database and making call using that user with defined duration
Post by: asymetrixs on March 13, 2013, 04:42:35 AM
Please describe in more detail what you want to do.

Maybe like

User A created in DB
User B calls User A
... etc. with information about what exactly should happen in the steps

A call will be disconnected when "timeout" is specified which tells yate how long a call may last.
Title: Re: create user from database and making call using that user with defined duration
Post by: smbakhtiar on March 13, 2013, 07:45:02 AM
First of all Thanks for your valuable replay.



Here is the brief discussion .It has four part

1. what is the scenario i want
2. yateadmin section
3. which configuration files i have to active
4. yate client section




 Description
 
 1. what is the senerion i want

    I have two user which is userA and userB.so i want to call userA to userB or call userB to userA using SIP protocol from yate client to both end
    (userA end and userB end or userB end to userA end).And also assign a call timeout for both user's.After a certain period the call will be disconnected.
    of any user's (userA or userB). 
   
 2. yateadmin section
   
    I am using mysql db for storing call information using this users,accounts,lines,routes,form,messages,cdr tables.

    I am connect yateadmin using mysql db

    Steps to user account creation

     In the Accounts menu I have create userA and userB
   
     In the Lines menu I have insert lines say 100 using Operations with single line    and also create 200 using Operations with single line
     
     In the YateAccounts I hace create two yate account for lines 100 and 200 using SIP protocol with following configuration
     
     

     protocol                sip                 sip       
     account                 100                 200
     username                userA               userB 
     authname                userA               userB
     password                123                 123   
     registrar               127.0.0.1:5060      127.0.0.1:5060
     outbound                127.0.0.1:5061      127.0.0.1:5061
     domain                  127.0.0.1           127.0.0.1
     localaddress            127.0.0.1           127.0.0.1
     description             Test SIP            Test SIP
     interval                600                 600   
     formats                   
     number                  100                 200
     modified checkbox       yes                 yes
     enable   checkbox       yes                 yes

     In the Routes menu how do add route can not understand.

 3. which configuration files i have to active

    I have to active the following files
 
    cdrbuild
    cdrfile
    mysqldb
    register
    rmanager

   configuration for the files i made
   
   *cdrbuild.conf
   --------------
   [general]

; resolution: keyword: Resolution for time representation: sec, msec or usec
resolution=msec

; guardtime: int: Time in ms to remember hungup channels to avoid race conditions
guardtime=5000

; updates: bool: Emit call cdr message when call status has changed
updates=true

; status: bool: Emit call cdr status messages for the call duration
status=false

; status_interval: int: The time interval in seconds to emit call cdr status messages
; Note: If status is set to false this interval will be ignored
; Default 60s
; Min 60s
; Max 600s
status_interval=60


[parameters]
; Each line consists of name=bool where name is the name of the parameter being
;  monitored while bool allows or disallows subsequent overwrites of the initial
;  non-empty value
; You can add your own monitored parameters that will appear in "call.cdr"

; The following parameters are handled by default but you can change their
;  overwrite behaviour
;billid=true
;reason=true
;address=false
;caller=false
;called=false
;calledfull=false
;username=false

; The following parameters are handled internally and cannot be changed:
;  time, chan, operation, cdrwrite, cdrtrack, cdrcreate, cdrid, runid,
;  direction, status, duration, billtime, ringtime


; Special section for time formatting
; Formatting rules
; YYYY | %Y -> Year (2012)
; YY | %y   -> Year, last two digits (00-99)
; MM | %m   -> Month as a decimal number (01-12)
; DD | %d   -> Day of the month (01-31)
; HH | %H   -> Hour in 24h format (00-23)
; mm | %M   -> Hour in 24h format (00-23)
; SS | %S   -> Second (00-60)
;              Note the value is rounded
; UTC       -> If present the time will represent the UTC time. If is missing
;              the time will represent local time zone
; N*u       -> Milliseconds and Microseconds.
;              Note! The value is rounded
;              EG: time: 1.123456
;                  s.u -> 1.1
;                  s.uu -> 1.12
;                  s.uuu -> 1.123
;                  s.uuuu -> 1.1234
;                  s.uuuuu -> 1.12346
;                  s.uuuuuu -> 1.123456
; Other formats may me used but they must correspond with C strftime method formats
; Important! If duplicate formats are ignored!
; Eg: date : 09 14 2012
;            YYYY YY DD DD mm DD-> 2012 YY 14 DD 09 DD

[formatted-timers]
; Append the call start time in call cdr message with the given format
; Eg: call_start_time=YY/MM/DD HH:mm:SS.uuuuuu UTC
call_start_time=YY/MM/DD HH:mm:SS.uuuuuu UTC

; Append the call answer time in call cdr message with the given format
; Eg: call_answer_time=YY/MM/DD HH:mm:SS.uuuuuu UTC
call_answer_time=YY/MM/DD HH:mm:SS.uuuuuu UTC

; Append the call hangup time in call cdr message with the given format
; Eg: call_hangup_time=YY/MM/DD HH:mm:SS.uuuuuu UTC
call_hangup_time=YY/MM/DD HH:mm:SS.uuuuuu UTC

; Append the call duration in call cdr message with the given format
; Allowed formats: HH mm SS N*u
; Eg: HH:mm:SS.uuu
duration_call=HH mm SS N*u

   --------------   
   

    *cdrfile.conf
   --------------
[general]
; file: string: Name of the file to write the CDR to
; You should check that this file is log rotated - see /etc/logrotate.d/yate
; Example: file=/var/log/yate-cdr.tsv
file=C:\Program Files\Yate\devel\cdrs\yate-cdr.csv

; tabs: bool: Use tab-separated instead of comma-separated if format is missing
tabs=true

; format: string: Custom format to use, overrides default. Each ${parameter}
;  is replaced with the value of that parameter in the call.cdr message

; tab-separated (.tsv)
;format=${time}   ${billid}   ${chan}   ${address}   ${caller}   ${called}   ${billtime}   ${ringtime}   ${duration}   ${direction}   ${status}   ${reason}

; comma-separated (.csv)
format=${time},"${billid}","${chan}","${address}","${caller}","${called}",${billtime},${ringtime},${duration},"${direction}","${status}","${reason}"
   
   -------------- 

  * mysqldb.conf
  ---------------
[general]
; This section is special - holds settings common to all connections

; priority: int: Handler priority
;priority=100


; Each other section in this file describes a database connection

;[default]
; The section name is used as the database connection name

; timeout: int: Query timeout in milliseconds - will be rounded to seconds
;timeout=10000

; initretry: int: Interval (in seconds) to retry creating failed connections. Setting it to 0 will disable retrying.
;initretry=10

; host: string: MySQL server to connect to, defaults to local
;host=

; port: int: Port on which the server is listening for connections
;port=0

; database: string: Name of the database to use in queries
;database=yate

; user: string: Username to use to access the database
;user=mysql

; password: string: Password to authenticate the user to the database server
;password=

; socket: string: UNIX socket to use for local connections
;socket=

; compress: bool: Enable use of compression protocol
;compress=disable

; encoding: string: Character set encoding used to communicate with the server
; If not set or empty will use the default for your system
; This setting is not available on older MySQL client libraries
;encoding=

; poolsize: int: Number of connections to establish for this account
; Minimum number of connections is 1
;poolsize=1

[yatetest]
host=127.0.0.1
database=test1
user=root
password=
;port=87
 
  ---------------
 
   * register.conf
  ---------------
[general]
; Global module settings that are read only at first initialization

; expires: int: Will execute the engine.timer query only every that many seconds
expires=30

; stoperror: regexp: Regular expression matching errors that will stop fallback
stoperror=busy


; The following parameters enable handling of individual messages
; Each must be enabled manually in this config file

; user.auth: bool: Activate handler on the "user.auth" message
user.auth=yes

; user.register: bool: Activate handler on the "user.register" message
user.register=yes

; user.unregister: bool: Activate handler on the "user.unregister" message
user.unregister=yes

; engine.timer: bool: Activate handler on the "engine.timer" message
engine.timer=yes

; call.preroute: bool: Activate handler on the "call.preroute" message
call.preroute=no

; call.route: bool: Activate handler on the "call.route" message
call.route=no

; call.cdr: bool: Activate handler on the "call.cdr" message
call.cdr=yes

; linetracker: bool: Activate line status tracking on "call.cdr"
linetracker=yes

; fallback: bool: Activate fallback routing handlers on the "chan.disconnected",
;  "call.answered" and "chan.hangup" messages
;fallback=no

; accounts: bool: Activate client registrations on "user.notify" and "engine.timer"
accounts=yes

; subscriptions: bool: Activate resource subscriptions support
;  You will also need to activate the handlers for the following messages:
;  "resource.subscribe", "user.notify", "call.cdr", "engine.timer"
;subscriptions=no

; resource.subscribe: bool: Activate handler on the "resource.subscribe" message
;resource.subscribe=no


[default]
; This section holds default settings for each of the following message handlers
; All these settings can be overriden in individual handler sections

; priority: int: Priority in Yate's handlers chain
priority=50

; account: string: Name of the database connection to use
;account=
account=yatetest

; In each of the following sections you have to specify the following:
; - initial query to execute when module is initialized
; - query to execute for each received message
; - result field to copy in message's textual return value (only for some)
; You can also override the settings from section [default]

; Sample queries below are for PostgreSQL
; Timestamps and intervals are unfortunately non-portable


[user.auth]
; Query and result name for the user.auth message
; The result must not be empty for password authentication to work
; The designated result field is mandatory in the columns to prevent a
;  configuration error from authorizing everybody. Use something
;  like "SELECT NULL AS password" if you really don't need it ever

query=SELECT password FROM users WHERE username='${username}' AND password IS NOT NULL AND password<>''
;result=password


[user.register]
; Query for the user.register message

query=UPDATE users SET location='${data},expires=CURRENT_TIMESTAMP + INTERVAL ${expires} SECOND' WHERE username='${username}'


[user.unregister]
; Query for the user.unregister message

query=UPDATE users SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND username='${username}'


[engine.timer]
; Query for the timer message that expires registrations
; Also look at the expires setting in section [general]

query=UPDATE users SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND expires<=CURRENT_TIMESTAMP


[call.preroute]
; Query and result name for the prerouting message

;query=
;priority=120


[call.route]
; Query and result name for the routing message

; offlineauto: boolean: Set the "offline" error for queries that return records but no route
offlineauto=yes

query=SELECT location,(CASE WHEN location IS NULL THEN 'offline' ELSE NULL END) AS error FROM users WHERE username='${called}'
;result=location
;priority=120


[call.cdr]
; Queries for the CDR updating message

; critical: boolean: Reject all registrations and routing if query fails
;critical=yes

;initquery=UPDATE cdr SET ended=true WHERE ended IS NULL OR NOT ended
;cdr_initialize=INSERT INTO cdr VALUES(TIMESTAMP 'EPOCH' + INTERVAL '${time} s','${chan}','${address}','${direction}','${billid}','${caller}','${called}',INTERVAL '${duration} s',INTERVAL '${billtime} s',INTERVAL '${ringtime} s','${status}','${reason}',false)
;cdr_update=UPDATE cdr SET address='${address}',direction='${direction}',billid='${billid}',caller='${caller}',called='${called}',duration=INTERVAL '${duration} s',billtime=INTERVAL '${billtime} s',ringtime=INTERVAL '${ringtime} s',status='${status}',reason='${reason}' WHERE chan='${chan}' AND time=TIMESTAMP 'EPOCH' + INTERVAL '${time} s'
;cdr_finalize=UPDATE cdr SET address='${address}',direction='${direction}',billid='${billid}',caller='${caller}',called='${called}',duration=INTERVAL '${duration} s',billtime=INTERVAL '${billtime} s',ringtime=INTERVAL '${ringtime} s',status='${status}',reason='${reason}',ended=true WHERE chan='${chan}' AND time=TIMESTAMP 'EPOCH' + INTERVAL '${time} s'

 -- Usage of the function in register.conf, only difference in cdr_insert/update and cdr_finalize is the last value for "ended"

cdr_insert=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', false);
cdr_update=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', false);
cdr_finalize=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', true);

   

[linetracker]
; Queries for the line usage tracker

; critical: boolean: Reject all registrations and routing if query fails
;critical=no

initquery=UPDATE users SET inuse=0
cdr_initialize=UPDATE users SET inuse=inuse+1 WHERE username='${external}'
cdr_finalize=UPDATE users SET inuse=(CASE WHEN inuse>0 THEN inuse-1 ELSE 0 END) WHERE username='${external}'


[accounts]
; Queries for registering as client to other servers

; query executed only once to create client registrations at startup
initquery=SELECT account,protocol,username,password,server FROM accounts WHERE enabled IS TRUE

; poll on timer to update registrations if database was changed externally
;timerquery=BEGIN; \
; SELECT (CASE WHEN enabled IS FALSE THEN 'logout' ELSE 'login' END) AS operation,\
; account,protocol,username,password,server FROM accounts WHERE modified IS TRUE; \
; UPDATE accounts SET modified=FALSE; \
; COMMIT

; update account status after receiving an user.notify
statusquery=UPDATE accounts SET status='${status}' WHERE account='${internalaccount}'


[resource.subscribe]
; Queries used for event subscribe and event state changes notification

; query executed on subscribe requests to check authorisation and refresh a subscription
;subscribe_subscribe=SELECT * FROM subscriptions_subscribe('${notifier}','${event}','${subscriber}','${data}','${notifyto}',INTERVAL '${expires} s') as t(notifier text,data text,subscriber text,event text,notifyto text,notifyseq int8)

; query executed on unsubscribe requests to check authorisation and remove a subscription
;subscribe_unsubscribe=SELECT * FROM subscriptions_unsubscribe('${notifier}','${event}','${subscriber}')

; query executed when nedded to get all subscribers for a specified notifier's event
;subscribe_notify=SELECT * FROM subscriptions_notify('${notifier}','${event}') as t(notifier text,data text,subscriber text,event text,notifyto text,notifyseq int8)

; query used to expire subscriptions
;subscribe_expire=SELECT * FROM subscriptions_expires() AS t(notifier text,data text,subscriber text,event text,notifyto text,notifyseq int8)

 
  ---------------
    *rmanager.conf
  ---------------
[general]
; Each section creates a connection listener in the Remote Manager.
; An empty (all defaults) general section is assumed only in server mode if the
;  configuration file is missing.

; port: int: TCP Port to listen on, 0 to disable the listener
;port=5038

; addr: ipaddress: IP address to bind to
;addr=127.0.0.1

; header: string: Header string to display on connect
;header=YATE ${version}-${release} (http://YATE.null.ro) ready on ${nodename}.

; password: string: Password required to authenticate as admin, default empty!
;password=

; userpass: string: Password to authenticate as observer user, default empty!
;userpass=

; timeout: int: Timeout until authentication succeeds in msec
;  Defaults to waiting 30s until closing an unauthenticated connection
;  Set to zero to disable else enforced minimum value is 5000 ms (5s)
;timeout=30000

; telnet: bool: Initiate TELNET negotiation on connect
;telnet=yes

; output: bool: Enable output as soon as connecting
;  This setting is ignored if an userpass is set
;output=no

; debug: bool: Enable local debug as soon as connecting
;  This setting is ignored if any password is set
;debug=no

; color: bool: Enable colorization debug as soon as connecting
;  This setting is ignored if telnet negotiation is disabled
;color=no

; interactive: bool: Disable the TCP coalescing to improve interactivity
;  This is almost never required and needs Yate to run as superuser
;interactive=no

; maxhistory: int: Number of distinct lines to preserve in the session history
;  The Up / Down arrow keys allow cycling through the history
;maxhistory=10

; context: string: SSL context to use to secure the connection
;  Setting a context enables SSL on the listener and overrides any domain
;context=

; domain: string: Domain used to identify the SSL context to use
;  Setting a domain enables SSL on the listener
;domain=

; verify: keyword: SSL handshake client certificate verification type
;  For acceptable values see the documentation of the openssl module
;  By default no client certificate is required
;verify=

; Initial aliases can be created for each connection
; Each declaration line starts with alias: and may include \0 as placeholder
;  for the line entered in rmanager and \1 ... \9 for individual components
; Example:
;  alias:cgu=control \1/ISUP unblock force=yes circuits=\2
 
  ---------------

4.  yate client section

    how do i configure yate client section and call using this configuration




Thanks

Bakhtiar
Title: Re: create user from database and making call using that user with defined duration
Post by: asymetrixs on March 14, 2013, 12:50:50 PM
Hi,

have you checked this?

http://docs.yate.ro/wiki/Redirecting_Calls_to_another_User_in_the_Regex_Module

For more information also see this:
http://yate.null.ro/pmwiki/index.php?n=Main.RegularExpressions

To end a call, you would also specify the "timeout" parameter. It takes millseconds and ends the call when the time is over
timeout=10000; would end after 10 seconds.

Regards
Title: Re: create user from database and making call using that user with defined duration
Post by: smbakhtiar on March 15, 2013, 05:56:59 AM
Hi,

I already read the topic, but could not understand how to implement it in the database . Here is what is i implemented in mysql database.

1. creating to user in user tables with the following information.
    username password
    100           100
    200           200
using this two account i have authenticate using yate client

2. in routes table i have insert the following information

    priority      protocol       prefix      ip                 port        account

    10             sip               100         127.0.0.1     5060       100

    10             sip                200         127.0.0.1     5060      200

3. and call the information using register.conf file using following information


[general]
; Global module settings that are read only at first initialization

; expires: int: Will execute the engine.timer query only every that many seconds
expires=60

; stoperror: regexp: Regular expression matching errors that will stop fallback
stoperror=busy\|noanswer


; The following parameters enable handling of individual messages
; Each must be enabled manually in this config file

; user.auth: bool: Activate handler on the "user.auth" message
user.auth=yes

; user.register: bool: Activate handler on the "user.register" message
user.register=yes

; user.unregister: bool: Activate handler on the "user.unregister" message
user.unregister=yes

; engine.timer: bool: Activate handler on the "engine.timer" message
engine.timer=yes

; call.preroute: bool: Activate handler on the "call.preroute" message
call.preroute=no

; call.route: bool: Activate handler on the "call.route" message
call.route=yes

; call.cdr: bool: Activate handler on the "call.cdr" message
call.cdr=yes

; linetracker: bool: Activate line status tracking on "call.cdr"
linetracker=yes

; fallback: bool: Activate fallback routing handlers on the "chan.disconnected",
;  "call.answered" and "chan.hangup" messages
;fallback=no

; accounts: bool: Activate client registrations on "user.notify" and "engine.timer"
accounts=yes
fallback=yes

; subscriptions: bool: Activate resource subscriptions support
;  You will also need to activate the handlers for the following messages:
;  "resource.subscribe", "user.notify", "call.cdr", "engine.timer"
;subscriptions=no

; resource.subscribe: bool: Activate handler on the "resource.subscribe" message
;resource.subscribe=no


[default]
; This section holds default settings for each of the following message handlers
; All these settings can be overriden in individual handler sections

; priority: int: Priority in Yate's handlers chain
priority=50

; account: string: Name of the database connection to use
;account=
account=yatetest

; In each of the following sections you have to specify the following:
; - initial query to execute when module is initialized
; - query to execute for each received message
; - result field to copy in message's textual return value (only for some)
; You can also override the settings from section [default]

; Sample queries below are for PostgreSQL
; Timestamps and intervals are unfortunately non-portable

[accounts]
; This  section is going to replace accfile

; message sent after receiving an engine.init
;initquery=SELECT * from initaccounts() as t(enabled bool,protocol text,username text,description text,interval text,formats text,authname text,password text,server text,gatekeeper text,domain text,registrar text,outbound text,localaddress text,modified bool, account text,id int4,status text,number text, gw bool)

initquery=SELECT `enabled` ,`protocol`,`username`,`description`,`interval`,`formats`,`authname`,`password`,`server`,
`gatekeeper`,`domain`,`registrar`,`outbound` ,`localaddress`, `modified`, `account` ,`id`,`status`,`number`,TRUE AS gw FROM accounts WHERE enabled=1 AND account IS NOT NULL AND username IS NOT NULL ORDER BY account

; message sent after receiving an engine.timer
;timerquery=SELECT * from updateaccounts() as t(enabled bool,protocol text,username text,description text,interval text,formats text,authname text,password text,server text,gatekeeper text,domain text,registrar text,outbound text,localaddress text,modified bool, account text,id int4,status text, number text, gw bool)

timerquery=UPDATE accounts SET modified=0 WHERE enabled=1 AND modified=1


; update status after user.notify

statusquery=UPDATE accounts SET status='${status}' WHERE account='${internalaccount}'


[fallback]
; This section is going to be enabled if fallback is desired


[user.auth]
; Query and result name for the user.auth message
; The result must not be empty for password authentication to work
; The designated result field is mandatory in the columns to prevent a
;  configuration error from authorizing everybody. Use something
;  like "SELECT NULL AS password" if you really don't need it ever

;query=SELECT password FROM users WHERE username='${username}' AND password IS NOT NULL AND password<>''
result=password

query=SELECT password FROM `lines` WHERE line='${username}'
AND password IS NOT NULL AND password<>''
result=password

[user.register]
; Query for the user.register message

;query=UPDATE users SET location='${data}',expires=CURRENT_TIMESTAMP + 'INTERVAL ${expires} SECOND' WHERE username='${username}'

query=UPDATE `lines` SET location='${data}',expires=CURRENT_TIMESTAMP + 'INTERVAL ${expires} SECOND' WHERE line='${username}'


[user.unregister]
; Query for the user.unregister message

;query=UPDATE users SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND username='${username}'

query=UPDATE `lines` SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND line='${username}'


[engine.timer]
; Query for the timer message that expires registrations
; Also look at the expires setting in section [general]

;query=UPDATE users SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND expires<=CURRENT_TIMESTAMP

query=UPDATE `lines` SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND expires<=CURRENT_TIMESTAMP

[call.preroute]
; Query and result name for the prerouting message

;query=
;priority=120


[call.route]
; Query and result name for the routing message

; offlineauto: boolean: Set the "offline" error for queries that return records but no route
;offlineauto=yes

;query=SELECT location,(CASE WHEN location IS NULL THEN 'offline' ELSE NULL END) AS error FROM users WHERE ;username='${called}'
;result=location
;priority=120

;query=SELECT * from getroute('${called}') as t(location text, ;called text, error text, line text)
;result=location
;priority=120

;query=select CONCAT('sip/sip:',prefix,'@',ip,':',port) location
 ;from `routes` where prefix=(select line from `lines` where ;line='${called}')
;result=location
;priority=120

query=select CONCAT('sip/sip:',`prefix`,'@',`ip`,':',`port`) location from `routes` where prefix='${called}'
result=location

[call.cdr]
; Queries for the CDR updating message

; critical: boolean: Reject all registrations and routing if query fails
;critical=yes

critical=no

;initquery=UPDATE cdr SET ended=true WHERE ended IS NULL OR NOT ended
;cdr_initialize=INSERT INTO cdr VALUES(TIMESTAMP 'EPOCH' + INTERVAL '${time} s','${chan}','${address}','${direction}','${billid}','${caller}','${called}',INTERVAL '${duration} s',INTERVAL '${billtime} s',INTERVAL '${ringtime} s','${status}','${reason}',false)
;cdr_update=UPDATE cdr SET address='${address}',direction='${direction}',billid='${billid}',caller='${caller}',called='${called}',duration=INTERVAL '${duration} s',billtime=INTERVAL '${billtime} s',ringtime=INTERVAL '${ringtime} s',status='${status}',reason='${reason}' WHERE chan='${chan}' AND time=TIMESTAMP 'EPOCH' + INTERVAL '${time} s'
;cdr_finalize=UPDATE cdr SET address='${address}',direction='${direction}',billid='${billid}',caller='${caller}',called='${called}',duration=INTERVAL '${duration} s',billtime=INTERVAL '${billtime} s',ringtime=INTERVAL '${ringtime} s',status='${status}',reason='${reason}',ended=true WHERE chan='${chan}' AND time=TIMESTAMP 'EPOCH' + INTERVAL '${time} s'

 -- Usage of the function in register.conf, only difference in cdr_insert/update and cdr_finalize is the last value for "ended"

initquery=UPDATE cdr SET ended=true WHERE ended IS NULL OR NOT ended

cdr_insert=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', false);
cdr_update=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', false);
cdr_finalize=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', true);

   

[linetracker]
; Queries for the line usage tracker

; critical: boolean: Reject all registrations and routing if query fails
;critical=no

;initquery=UPDATE users SET inuse=0
;cdr_initialize=UPDATE users SET inuse=inuse+1 WHERE username='${external}'
;cdr_finalize=UPDATE users SET inuse=(CASE WHEN inuse>0 THEN inuse-1 ELSE 0 END) WHERE username='${external}'

initquery=UPDATE `lines` SET inuse=0

cdr_initialize=UPDATE `lines` SET inuse=inuse+1 WHERE line='${external}'

cdr_finalize=UPDATE `lines` SET inuse=(CASE WHEN inuse>0 THEN inuse-1 ELSE 0 END) WHERE line='${external}'

;[accounts]
; Queries for registering as client to other servers

; query executed only once to create client registrations at startup
;initquery=SELECT account,protocol,username,password,server FROM accounts WHERE enabled IS TRUE

; poll on timer to update registrations if database was changed externally
;timerquery=BEGIN; \
; SELECT (CASE WHEN enabled IS FALSE THEN 'logout' ELSE 'login' END) AS operation,\
; account,protocol,username,password,server FROM accounts WHERE modified IS TRUE; \
; UPDATE accounts SET modified=FALSE; \
; COMMIT

; update account status after receiving an user.notify
statusquery=UPDATE accounts SET status='${status}' WHERE account='${internalaccount}'


[resource.subscribe]
; Queries used for event subscribe and event state changes notification

; query executed on subscribe requests to check authorisation and refresh a subscription
;subscribe_subscribe=SELECT * FROM subscriptions_subscribe('${notifier}','${event}','${subscriber}','${data}','${notifyto}',INTERVAL '${expires} s') as t(notifier text,data text,subscriber text,event text,notifyto text,notifyseq int8)

; query executed on unsubscribe requests to check authorisation and remove a subscription
;subscribe_unsubscribe=SELECT * FROM subscriptions_unsubscribe('${notifier}','${event}','${subscriber}')

; query executed when nedded to get all subscribers for a specified notifier's event
;subscribe_notify=SELECT * FROM subscriptions_notify('${notifier}','${event}') as t(notifier text,data text,subscriber text,event text,notifyto text,notifyseq int8)

; query used to expire subscriptions
;subscribe_expire=SELECT * FROM subscriptions_expires() AS t(notifier text,data text,subscriber text,event text,notifyto text,notifyseq int8)


4. now when i call the from yate client using 100 account to 200 it ringing but some error happend which store the call information with the following information in cdr table like



idcdr   sqltime   yatetime   billid   chan   address   addressport   caller   callername   called   billtime   ringtime   duration   direction   status   reason   ended
742   3/15/2013 17:26   1363346793   1363346713-20   sip/39   127.0.0.1   5060   100      200   0   0   0.01   incoming   rejected   Call is looping   1
743   3/15/2013 17:26   1363346793   1363346713-19   sip/38   127.0.0.1   5060   100      200   0   0   0.07   outgoing   outgoing   Call is looping   1
745   3/15/2013 17:26   1363346792   1363346713-18   sip/36   127.0.0.1   5060   100      200   0   0   0.2   outgoing   outgoing   Too Many Hops   1

5. after few second ringing the call will be disconnected automatically.


please help me

Thanks
Bakhtiar

   
   
Title: Re: create user from database and making call using that user with defined duration
Post by: smbakhtiar on March 20, 2013, 11:52:47 PM
waiting for your replay
Title: Re: create user from database and making call using that user with defined duration
Post by: Diana Cionoiu on March 25, 2013, 11:06:27 AM
just use the maxtime paramter to limit the call duration.
Title: Re: create user from database and making call using that user with defined duration
Post by: smbakhtiar on March 28, 2013, 04:21:43 AM
Thanks for the replay



I have another question that is , is it possible to generate call using signaling what i mean that what is the basic call generation happened that we configure the yate server and then make call from yate client to yate client from using yate server using SIP protocol where using RTP .But i want call will be established using signaling using yate client to yate client without RTP is it possible , if possible , then how?

Bakhtiar