// Touch creates a new Command to reset the timeout for
// a given message (by id)
515356
func Touch(id MessageID) *Command {
	var params = [][]byte{id[:]}
	return &Command{[]byte("TOUCH"), params, nil}
}
640377
func (asyncResult *AsyncResult) Touch() ([]reflect.Value, error) {
	if asyncResult.backend == nil {
		return nil, ErrBackendNotConfigured
	}

	asyncResult.GetState()

	// Purge state if we are using AMQP backend
	if asyncResult.backend.IsAMQP() && asyncResult.taskState.IsCompleted() {
		asyncResult.backend.PurgeState(asyncResult.taskState.TaskUUID)
	}

	if asyncResult.taskState.IsFailure() {
		return nil, errors.New(asyncResult.taskState.Error)
	}

	if asyncResult.taskState.IsSuccess() {
		return tasks.ReflectTaskResults(asyncResult.taskState.Results)
	}

	return nil, nil
}
725640
func (s *State) Message(channelID, messageID string) (*Message, error) {
	if s == nil {
		return nil, ErrNilState
	}

	c, err := s.Channel(channelID)
	if err != nil {
		return nil, err
	}

	s.RLock()
	defer s.RUnlock()

	for _, m := range c.Messages {
		if m.ID == messageID {
			return m, nil
		}
	}

	return nil, ErrStateNotFound
}
1027028
func (s SimpleHeart) touch() {
	if err := s.strategy.Touch(s.Location, s.ID, s.pool); err != nil {
		s.errs <- err
	}
}
41690
func Timeout(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "timeout", Listener: listener}
}
973530
func touch(path string) {
	t := time.Now()
	if err := os.Chtimes(path, t, t); err != nil {
		log.Printf("failed to touch %s: %s", path, err)
	}
}
388699
func Sleep(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	dur := p.Get("duration", 10*time.Millisecond).(time.Duration)
	msg := p.Get("messages", "Sleeping").(string)
	log.Info(c, msg)
	time.Sleep(dur)
	log.Info(c, "Woke up.")
	return true, nil
}
424243
func (m *Meta) touch(ptr interface{}) {
	if m.touched == nil {
		m.touched = make(map[interface{}]struct{}, 1)
	}
	m.touched[ptr] = struct{}{}
}
600399
func (b *UpdateService) Timeout(timeout string) *UpdateService {
	b.timeout = timeout
	return b
}
667595
func (c *Collection) Touch(key string, expiration uint32, opts *TouchOptions) (mutOut *MutationResult, errOut error) {
	if opts == nil {
		opts = &TouchOptions{}
	}

	span := c.startKvOpTrace(opts.ParentSpanContext, "Touch")
	defer span.Finish()

	ctx, cancel := c.context(opts.Context, opts.Timeout)
	if cancel != nil {
		defer cancel()
	}

	res, err := c.touch(ctx, span.Context(), key, expiration, *opts)
	if err != nil {
		return nil, err
	}

	return res, nil
}
1090104
func ChannelAfterTouch(channel, vel int) *Event {
	return &Event{
		MsgChan:  uint8(channel),
		MsgType:  uint8(EventByteMap["ChannelAfterTouch"]),
		Pressure: uint8(vel),
	}
}
1058306
func touch(state *messages.InstanceCache, instanceID string, now time.Time) {
	entry := state.Entries[instanceID]
	if entry == nil {
		entry = &messages.InstanceCache_Entry{}
		if state.Entries == nil {
			state.Entries = map[string]*messages.InstanceCache_Entry{}
		}
		state.Entries[instanceID] = entry
	}
	entry.LastAccess = google.NewTimestamp(now)
}
1119195
func (sprite *sprite) AddTouchListener(listener peer.TouchListener) {
	simlog.FuncIn()
	sprite.Sprite.AddTouchListener(listener)
	simlog.FuncOut()
}
237377
func TouchEvent(x, y, id, action int) {
	Input.Mouse.X = float32(x) / opts.GlobalScale.X
	Input.Mouse.Y = float32(y) / opts.GlobalScale.Y
	switch action {
	case C.UITouchPhaseBegan, C.UITouchPhaseStationary:
		Input.Mouse.Action = Press
		Input.Touches[id] = Point{
			X: float32(x) / opts.GlobalScale.X,
			Y: float32(y) / opts.GlobalScale.Y,
		}
	case C.UITouchPhaseEnded, C.UITouchPhaseCancelled:
		Input.Mouse.Action = Release
		delete(Input.Touches, id)
	case C.UITouchPhaseMoved:
		Input.Mouse.Action = Move
		Input.Touches[id] = Point{
			X: float32(x) / opts.GlobalScale.X,
			Y: float32(y) / opts.GlobalScale.Y,
		}
	}
}
711011
func (c *connection) SetIdleTimeout(timeout time.Duration) {
	c.conn.SetIdleTimeout(timeout)
}
420832
func (message Message) setContact(peer *Peer) Message {
	message.Contact = &Contact{
		External: peer.GetExternal(),
		Port:     peer.GetPort(),
		Address:  peer.GetPeerAddress(),
	}
	return message
}
529795
func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
	b.Log.Debugf("=> Receiving %#v", msg)

	// Delete message
	if msg.Event == config.EventMsgDelete {
		if msg.ID == "" {
			// No message ID in case action is executed on a message sent before the bridge was started
			// and then the bridge cache doesn't have this message ID mapped

			// TODO 42wim Doesn't the app get clogged with a ton of IDs after some time of running?
			// WhatsApp allows to set any ID so in that case we could use external IDs and don't do mapping
			// but external IDs are not set
			return "", nil
		}
		// TODO delete message on WhatsApp https://github.com/Rhymen/go-whatsapp/issues/100
		return "", nil
	}

	// Edit message
	if msg.ID != "" {
		b.Log.Debugf("updating message with id %s", msg.ID)

		msg.Text += " (edited)"
		// TODO handle edit as a message reply with updated text
	}

	//// TODO Handle Upload a file
	//if msg.Extra != nil {
	//	for _, rmsg := range helper.HandleExtra(&msg, b.General) {
	//		b.c.SendMessage(roomID, rmsg.Username+rmsg.Text)
	//	}
	//	if len(msg.Extra["file"]) > 0 {
	//		return b.handleUploadFile(&msg, roomID)
	//	}
	//}

	// Post text message
	text := whatsapp.TextMessage{
		Info: whatsapp.MessageInfo{
			RemoteJid: msg.Channel, // which equals to group id
		},
		Text: msg.Username + msg.Text,
	}

	b.Log.Debugf("=> Sending %#v", msg)

	// create message ID
	// TODO follow and act if https://github.com/Rhymen/go-whatsapp/issues/101 implemented
	bytes := make([]byte, 10)
	if _, err := rand.Read(bytes); err != nil {
		b.Log.Warn(err.Error())
	}
	text.Info.Id = strings.ToUpper(hex.EncodeToString(bytes))

	err := b.conn.Send(text)

	return text.Info.Id, err
}