-
Notifications
You must be signed in to change notification settings - Fork 251
/
xep0301.ts
91 lines (82 loc) · 2.17 KB
/
xep0301.ts
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// ====================================================================
// XEP-0301: In-Band Real Time Text
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0301.html
// Version: 1.0 (2013-10-082)
// ====================================================================
import { attribute, DefinitionOptions, integerAttribute, text } from '../jxt';
import { NS_RTT_0 } from '../Namespaces';
declare module './' {
export interface Message {
rtt?: RTT;
}
}
export interface RTT {
id?: string;
event?: 'new' | 'reset' | 'edit' | 'init' | 'cancel';
seq?: number;
actions?: RTTAction[];
}
export interface RTTInsert {
type: 'insert';
position?: number;
text?: string;
baseTime?: number;
}
export interface RTTErase {
type: 'erase';
position?: number;
length?: number;
baseTime?: number;
}
export interface RTTWait {
type: 'wait';
duration: number;
baseTime?: number;
}
export type RTTAction = RTTInsert | RTTErase | RTTWait;
const Protocol: DefinitionOptions[] = [
{
element: 'rtt',
fields: {
event: attribute('event', 'edit'),
id: attribute('id'),
seq: integerAttribute('seq')
},
namespace: NS_RTT_0,
path: 'message.rtt'
},
{
aliases: [{ path: 'message.rtt.actions', multiple: true }],
element: 't',
fields: {
position: integerAttribute('p'),
text: text()
},
namespace: NS_RTT_0,
type: 'insert',
typeField: 'type'
},
{
aliases: [{ path: 'message.rtt.actions', multiple: true }],
element: 'e',
fields: {
length: integerAttribute('n', 1),
position: integerAttribute('p')
},
namespace: NS_RTT_0,
type: 'erase',
typeField: 'type'
},
{
aliases: [{ multiple: true, path: 'message.rtt.actions' }],
element: 'w',
fields: {
duration: integerAttribute('n', 0)
},
namespace: NS_RTT_0,
type: 'wait',
typeField: 'type'
}
];
export default Protocol;