-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
50 lines (44 loc) · 1.47 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Timers;
namespace TypingTimer
{
/// <summary>
/// Concept for sending a Typing signal in a chat after xx seconds while the user is Typing
/// </summary>
class Program
{
private static Timer TypingSignalTimer;
private static Timer TypingEndSignalTimer;
static void Main(string[] args)
{
Start();
Console.ReadLine();
}
private static void Start()
{
TypingSignalTimer = new Timer(2500) { AutoReset = false };
TypingSignalTimer.Elapsed += CanSendTypingSignal;
TypingEndSignalTimer = new Timer(3500) { AutoReset = false };
TypingEndSignalTimer.Elapsed += CanSendStopTypingSignal;
Console.WriteLine("Start typing \n");
var key = Console.ReadKey();
while (key.Key.ToString() != "Esc")
{
TypingSignalTimer.Start();
TypingEndSignalTimer.Stop();
TypingEndSignalTimer.Start();
key = Console.ReadKey();
}
}
private static void CanSendTypingSignal(object sender, ElapsedEventArgs e)
{
//Send SignalR signal
Console.WriteLine($"\n\n User is typing");
}
private static void CanSendStopTypingSignal(object sender, ElapsedEventArgs e)
{
//Send SignalR signal
Console.WriteLine($"\n User stopped typing");
}
}
}