@@ -32,6 +32,11 @@ func (c *channel) copyValue(v interface{}) (interface{}, error) {
3232 }
3333 return c .copySender (val )
3434 }
35+ case * channelWrapper :
36+ if val .direction == inbound {
37+ return c .copyReceiver (val )
38+ }
39+ return c .copySender (val )
3540 case * net.TCPConn :
3641 // Do nothing until socket support is added
3742 case * net.UDPConn :
@@ -48,11 +53,16 @@ func (c *channel) copyValue(v interface{}) (interface{}, error) {
4853 return c .copyReceiver (val )
4954 case map [string ]interface {}:
5055 return c .copyChannelMessage (val )
51- case struct {}:
52- return c .copyStructure (v )
53- case * struct {}:
54- return c .copyStructure (v )
56+ case map [interface {}]interface {}:
57+ return c .copyChannelInterfaceMessage (val )
5558 default :
59+ if rv := reflect .ValueOf (v ); rv .Kind () == reflect .Ptr {
60+ if rv .Elem ().Kind () == reflect .Struct {
61+ return c .copyStructValue (rv .Elem ())
62+ }
63+ } else if rv .Kind () == reflect .Struct {
64+ return c .copyStructValue (rv )
65+ }
5666 }
5767 return v , nil
5868}
@@ -135,6 +145,23 @@ func (c *channel) copyChannelMessage(m map[string]interface{}) (interface{}, err
135145 return mCopy , nil
136146}
137147
148+ func (c * channel ) copyChannelInterfaceMessage (m map [interface {}]interface {}) (interface {}, error ) {
149+ mCopy := make (map [string ]interface {})
150+ for k , v := range m {
151+ vCopy , vErr := c .copyValue (v )
152+ if vErr != nil {
153+ return nil , vErr
154+ }
155+ keyStr , ok := k .(string )
156+ if ! ok {
157+ return nil , errors .New ("invalid non string key" )
158+ }
159+ mCopy [keyStr ] = vCopy
160+ }
161+
162+ return mCopy , nil
163+ }
164+
138165func (c * channel ) copyStructure (m interface {}) (interface {}, error ) {
139166 v := reflect .ValueOf (m )
140167 if v .Kind () == reflect .Ptr {
@@ -143,6 +170,10 @@ func (c *channel) copyStructure(m interface{}) (interface{}, error) {
143170 if v .Kind () != reflect .Struct {
144171 return nil , errors .New ("invalid non struct type" )
145172 }
173+ return c .copyStructValue (v )
174+ }
175+
176+ func (c * channel ) copyStructValue (v reflect.Value ) (interface {}, error ) {
146177 mCopy := make (map [string ]interface {})
147178 t := v .Type ()
148179 for i := 0 ; i < v .NumField (); i ++ {
0 commit comments