예제 #1
0
// Map the Receiver to a chan<- string for the next Handler(s)
// Map the Receiver to a <-chan string for the next Handler(s)
func (c *MessageConnection) mapChannels(context martini.Context) {
	context.Set(reflect.ChanOf(reflect.SendDir, reflect.TypeOf(c.Sender).Elem()), reflect.ValueOf(c.Sender))
	context.Set(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(c.Receiver).Elem()), reflect.ValueOf(c.Receiver))
}
예제 #2
0
// Map the Sender to a chan<- *Message for the next Handler(s)
// Map the Receiver to a <-chan *Message for the next Handler(s)
func (c *JSONConnection) mapChannels(context martini.Context) {
	context.Set(reflect.ChanOf(reflect.SendDir, c.Sender.Type().Elem()), c.Sender)
	context.Set(reflect.ChanOf(reflect.RecvDir, c.Receiver.Type().Elem()), c.Receiver)
}
예제 #3
0
// Helper method to map default channels in the context
// Map the Error Channel to a <-chan error for the next Handler(s)
// Map the Disconnect Channel to a chan<- bool for the next Handler(s)
// Map the Done Channel to a <-chan bool for the next Handler(s)
func (c *Connection) mapDefaultChannels(context martini.Context) {
	context.Set(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(c.Error).Elem()), reflect.ValueOf(c.Error))
	context.Set(reflect.ChanOf(reflect.SendDir, reflect.TypeOf(c.Disconnect).Elem()), reflect.ValueOf(c.Disconnect))
	context.Set(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(c.Done).Elem()), reflect.ValueOf(c.Done))
}