[asterisk-dev] [Code Review] Group Variables

Mark Michelson reviewboard at asterisk.org
Thu Apr 7 19:06:23 CDT 2011



> On 2011-04-07 18:28:26, Paul Belanger wrote:
> > /trunk/funcs/func_groupcount.c, line 380
> > <https://reviewboard.asterisk.org/r/464/diff/3/?file=8060#file8060line380>
> >
> >     Is this the correct syntax?
> >     
> >     if (!(chan = ast_channel_get_by_name(channel))) {
> >          astman_send_error(s, m, "Channel not found");
> >          return AMI_SUCCESS;
> >     }

Either way works. It's really a matter of personal taste. Paul's method is used more often in Asterisk, but I don't believe there's a specific coding guideline enforcing it.


- Mark


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/464/#review3310
-----------------------------------------------------------


On 2010-02-09 11:01:51, kobaz wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/464/
> -----------------------------------------------------------
> 
> (Updated 2010-02-09 11:01:51)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> This patch allows for setting variables on a group of channels.
> First a channel is assigned a group via dialplan GROUP() or GroupSet via the ami (new command)
> Then, variables can be set on that group with the GROUP_VAR() dialplan function, or GroupVarSet in the manager
> 
> This patch also adds manager events for channel group changes, and variable updates
> 
> When a group is no longer used (all channels referencing the group are hung up, or all channels referencing the group have their group changed/unset), variables are destroyed
> 
> new manager commands:
> GroupSet - adds functionality to the manager to be able to set a GROUP() on a channel.
> GroupsShowChannels - show each channel and it's associated groups (a channel will be repeated for each group at category it's a member of)
> GroupsShowVariables - show variables in each group at category, one event per group, all variables are contained in each group at category event
> GroupVarSet - set a group variable (the group has to exist)
> GroupVarGet - get a group variable
> 
> new manager events:
> GroupCreate
> GroupChannelAdd
> GroupChannelRemove
> GroupDestroy
> GroupVarSet
> 
> Example AMI:
> Action: GroupVarSet
> Group: 1000
> Category: ConferenceBridge
> Variable: LastUpdateCheck
> Value: 1263502512
> 
> Example CLI:
> demo1*CLI> group show variables
> Group    Variables    Category
> 1000            ConferenceBridge
>     LastUpdateCheck=1263502512
> 1000            ConferenceModerator
> 2 active groups
> 
> 
> Adds support for:
>   Group variables
>      dialplan access: GROUP_VAR()
>      cli access: group show variables
>      manager access: GroupVarSet GroupVarGet
>   Group information: 
>      manager access: GroupSet GroupsShow GroupsShowChannels GroupsShowVariables
>   
> 
> 
> This addresses bug 16614.
>     https://issues.asterisk.org/view.php?id=16614
> 
> 
> Diffs
> -----
> 
>   /trunk/funcs/func_groupcount.c 240226 
>   /trunk/include/asterisk/app.h 240226 
>   /trunk/include/asterisk/channel.h 240226 
>   /trunk/main/app.c 240226 
>   /trunk/main/cli.c 240226 
> 
> Diff: https://reviewboard.asterisk.org/r/464/diff
> 
> 
> Testing
> -------
> 
> dialplan:
>     Set(GROUP()=foo);
>     Set(GROUP()=foobar at foocat);
> 
>     Set(GROUP_VAR(foo,myvar)=123);
>     Set(GROUP_VAR(foo,myvar2)=456);
>     NoOp(${GROUP_VAR(foo,myvar)});
>     NoOp(${GROUP_VAR(foo,myvar2)});
> 
>     Set(GROUP_VAR(foobar at foocat,myvar)=123);
>     NoOp(${GROUP_VAR(foobar at foocat,myvar)});
> 
>     Set(GROUP_VAR(something,myvar)=123);
>     NoOp(${GROUP_VAR(something,myvar)});
> 
>     Wait(10000);
>     Hangup();
> 
> 
> CLI:
> -------------------
> > group show channels
> -------------------
> channel                    Group                 Category
> IAX2/branch-15569          foo                   (default)
> IAX2/branch-15569          foobar                foocat
> 2 active channels
> 
> -------------------
> > group show variables
> -------------------
> Group    Variables    Category
> foo                   (Default)
>      myvar2=456
>      myvar=123
> foobar                foocat
>      myvar=123
> 2 active groups
> 
> 
> AMI:
> -------------------
> Action: GroupsShow
> -------------------
> Response: Success
> Eventlist: start
> Message: Groups will follow
> 
> Event: GroupsShow
> Group: foo
> Category:
> 
> Event: GroupsShow
> Group: foobar
> Category: foocat
> 
> Event: GroupsShowComplete
> EventList: Complete
> ListItems: 2
> 
> 
> -------------------
> Action: GroupsShowChannels
> -------------------
> Response: Success
> Eventlist: start
> Message: Group channels will follow
> 
> Event: GroupsShowChannels
> Group: foo
> Category:
> Channel: IAX2/branch-14981
> 
> Event: GroupsShowChannels
> Group: foobar
> Category: foocat
> Channel: IAX2/branch-14981
> 
> Event: GroupsShowChannelsComplete
> EventList: Complete
> ListItems: 2
> 
> 
> -------------------
> Action: GroupsShowVariables
> -------------------
> Response: Success
> Eventlist: start
> Message: Group variables will follow
> 
> Event: GroupsShowVariables
> Group: foo
> Category:
> VariablesStart: Variables will follow
> myvar2: 456
> myvar: 123
> 
> 
> Event: GroupsShowVariables
> Group: foobar
> Category: foocat
> VariablesStart: Variables will follow
> myvar: 123
> 
> Event: GroupsShowVariablesComplete
> EventList: Complete
> ListItems: 2
> 
> 
> -------------------
> Action: GroupVarGet
> Group: foo
> Variable: myvar
> -------------------
> Response: Success
> Message: Result will follow
> 
> Event: GroupVarGetResponse
> Group: foo
> Category:
> Variable: myvar
> Value: 123
> 
> 
> -------------------
> Action: GroupVarSet
> Group: foobar
> Category: foocat
> Variable: something
> Value: 1238091283123
> -------------------
> 
> Response: Success
> Message: Variable Set
> 
> 
> -------------------
> Action: GroupVarSet
> Group: doesntexist
> Category: foocat
> Variable: something
> Value: 1238091283123
> -------------------
> 
> Response: Error
> Message: Variable set failed (group doesn't exist)
> 
> 
> Thanks,
> 
> kobaz
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110408/91262b13/attachment.htm>


More information about the asterisk-dev mailing list