diff --git a/console/publish.go b/console/publish.go
new file mode 100644
index 000000000..a407c8023
--- /dev/null
+++ b/console/publish.go
@@ -0,0 +1,64 @@
+/*
+Rating system designed to be used in VoIP Carriers World
+Copyright (C) 2012-2015 ITsysCOM
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package console
+
+import "github.com/cgrates/cgrates/engine"
+
+func init() {
+ c := &CmdPublish{
+ name: "publish",
+ rpcMethod: "PubSubV1.Publish",
+ }
+ commands[c.Name()] = c
+ c.CommandExecuter = &CommandExecuter{c}
+}
+
+type CmdPublish struct {
+ name string
+ rpcMethod string
+ rpcParams *engine.PublishInfo
+ *CommandExecuter
+}
+
+func (self *CmdPublish) Name() string {
+ return self.name
+}
+
+func (self *CmdPublish) RpcMethod() string {
+ return self.rpcMethod
+}
+
+func (self *CmdPublish) RpcParams(ptr bool) interface{} {
+ if self.rpcParams == nil {
+ self.rpcParams = &engine.PublishInfo{}
+ }
+ if ptr {
+ return self.rpcParams
+ }
+ return *self.rpcParams
+}
+
+func (self *CmdPublish) PostprocessRpcParams() error {
+ return nil
+}
+
+func (self *CmdPublish) RpcResult() interface{} {
+ var s string
+ return &s
+}
diff --git a/console/show_subscribers.go b/console/show_subscribers.go
new file mode 100644
index 000000000..b4591328d
--- /dev/null
+++ b/console/show_subscribers.go
@@ -0,0 +1,64 @@
+/*
+Rating system designed to be used in VoIP Carriers World
+Copyright (C) 2012-2015 ITsysCOM
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package console
+
+import "time"
+
+func init() {
+ c := &CmdShowSubscribers{
+ name: "show_subscribers",
+ rpcMethod: "PubSubV1.ShowSubscribers",
+ }
+ commands[c.Name()] = c
+ c.CommandExecuter = &CommandExecuter{c}
+}
+
+type CmdShowSubscribers struct {
+ name string
+ rpcMethod string
+ rpcParams *StringWrapper
+ *CommandExecuter
+}
+
+func (self *CmdShowSubscribers) Name() string {
+ return self.name
+}
+
+func (self *CmdShowSubscribers) RpcMethod() string {
+ return self.rpcMethod
+}
+
+func (self *CmdShowSubscribers) RpcParams(ptr bool) interface{} {
+ if self.rpcParams == nil {
+ self.rpcParams = &StringWrapper{}
+ }
+ if ptr {
+ return self.rpcParams
+ }
+ return *self.rpcParams
+}
+
+func (self *CmdShowSubscribers) PostprocessRpcParams() error {
+ return nil
+}
+
+func (self *CmdShowSubscribers) RpcResult() interface{} {
+ var s map[string]map[string]time.Time
+ return &s
+}
diff --git a/console/subscribe.go b/console/subscribe.go
new file mode 100644
index 000000000..ee8c27bd7
--- /dev/null
+++ b/console/subscribe.go
@@ -0,0 +1,64 @@
+/*
+Rating system designed to be used in VoIP Carriers World
+Copyright (C) 2012-2015 ITsysCOM
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package console
+
+import "github.com/cgrates/cgrates/engine"
+
+func init() {
+ c := &CmdSubscribe{
+ name: "subscribe",
+ rpcMethod: "PubSubV1.Subscribe",
+ }
+ commands[c.Name()] = c
+ c.CommandExecuter = &CommandExecuter{c}
+}
+
+type CmdSubscribe struct {
+ name string
+ rpcMethod string
+ rpcParams *engine.SubscribeInfo
+ *CommandExecuter
+}
+
+func (self *CmdSubscribe) Name() string {
+ return self.name
+}
+
+func (self *CmdSubscribe) RpcMethod() string {
+ return self.rpcMethod
+}
+
+func (self *CmdSubscribe) RpcParams(ptr bool) interface{} {
+ if self.rpcParams == nil {
+ self.rpcParams = &engine.SubscribeInfo{}
+ }
+ if ptr {
+ return self.rpcParams
+ }
+ return *self.rpcParams
+}
+
+func (self *CmdSubscribe) PostprocessRpcParams() error {
+ return nil
+}
+
+func (self *CmdSubscribe) RpcResult() interface{} {
+ var s string
+ return &s
+}
diff --git a/console/unsubscribe.go b/console/unsubscribe.go
new file mode 100644
index 000000000..66f02d741
--- /dev/null
+++ b/console/unsubscribe.go
@@ -0,0 +1,64 @@
+/*
+Rating system designed to be used in VoIP Carriers World
+Copyright (C) 2012-2015 ITsysCOM
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package console
+
+import "github.com/cgrates/cgrates/engine"
+
+func init() {
+ c := &CmdUnsubscribe{
+ name: "unsubscribe",
+ rpcMethod: "PubSubV1.Unsubscribe",
+ }
+ commands[c.Name()] = c
+ c.CommandExecuter = &CommandExecuter{c}
+}
+
+type CmdUnsubscribe struct {
+ name string
+ rpcMethod string
+ rpcParams *engine.SubscribeInfo
+ *CommandExecuter
+}
+
+func (self *CmdUnsubscribe) Name() string {
+ return self.name
+}
+
+func (self *CmdUnsubscribe) RpcMethod() string {
+ return self.rpcMethod
+}
+
+func (self *CmdUnsubscribe) RpcParams(ptr bool) interface{} {
+ if self.rpcParams == nil {
+ self.rpcParams = &engine.SubscribeInfo{}
+ }
+ if ptr {
+ return self.rpcParams
+ }
+ return *self.rpcParams
+}
+
+func (self *CmdUnsubscribe) PostprocessRpcParams() error {
+ return nil
+}
+
+func (self *CmdUnsubscribe) RpcResult() interface{} {
+ var s string
+ return &s
+}
diff --git a/engine/pubsub.go b/engine/pubsub.go
index 8bc8ecee8..65b9b3cc7 100644
--- a/engine/pubsub.go
+++ b/engine/pubsub.go
@@ -26,6 +26,7 @@ type PublisherSubscriber interface {
Subscribe(SubscribeInfo, *string) error
Unsubscribe(SubscribeInfo, *string) error
Publish(PublishInfo, *string) error
+ ShowSubscribers(string, *map[string]map[string]time.Time) error
}
type PubSub struct {
@@ -138,6 +139,11 @@ func (ps *PubSub) Publish(pi PublishInfo, reply *string) error {
return nil
}
+func (ps *PubSub) ShowSubscribers(in string, out *map[string]map[string]time.Time) error {
+ *out = ps.subscribers
+ return nil
+}
+
type ProxyPubSub struct {
Client *rpcclient.RpcClient
}
@@ -151,11 +157,15 @@ func NewProxyPubSub(addr string, reconnects int) (*ProxyPubSub, error) {
}
func (ps *ProxyPubSub) Subscribe(si SubscribeInfo, reply *string) error {
- return ps.Client.Call("PubSub.Subscribe", si, reply)
+ return ps.Client.Call("PubSubV1.Subscribe", si, reply)
}
func (ps *ProxyPubSub) Unsubscribe(si SubscribeInfo, reply *string) error {
- return ps.Client.Call("PubSub.Unsubscribe", si, reply)
+ return ps.Client.Call("PubSubV1.Unsubscribe", si, reply)
}
func (ps *ProxyPubSub) Publish(pi PublishInfo, reply *string) error {
- return ps.Client.Call("PubSub.Publish", pi, reply)
+ return ps.Client.Call("PubSubV1.Publish", pi, reply)
+}
+
+func (ps *ProxyPubSub) ShowSubscribers(in string, reply *map[string]map[string]time.Time) error {
+ return ps.Client.Call("PubSubV1.ShowSubscribers", in, reply)
}