fr.quatrevieux.singleinstance.ipc.MessageSender   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 34
ccs 4
cts 4
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A send(String) 0 2 1
A send(String,byte[]) 0 2 1
send(Message) 0 1 ?
1
/*
2
 * This file is part of SingleInstance.
3
 *
4
 * SingleInstance is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * SingleInstance is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with SingleInstance.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.singleinstance.ipc;
21
22
import java.io.IOException;
23
24
/**
25
 * Send IPC message to the distant instance
26
 */
27
public interface MessageSender {
28
    /**
29
     * Send a simple message with payload
30
     *
31
     * @param message The message name
32
     * @param data The message payload
33
     *
34
     * @see SimpleMessage
35
     * @throws IOException When cannot send message
36
     */
37
    default public void send(String message, byte[] data) throws IOException {
38 1
        send(new SimpleMessage(message, data));
39 1
    }
40
41
    /**
42
     * Send a simple message without payload
43
     *
44
     * @param message The message name
45
     *
46
     * @see SimpleMessage
47
     * @throws IOException When cannot send message
48
     */
49
    default public void send(String message) throws IOException {
50 1
        send(new SimpleMessage(message));
51 1
    }
52
53
    /**
54
     * Send a message
55
     *
56
     * @param message The message
57
     *
58
     * @throws IOException When cannot send message
59
     */
60
    public void send(Message message) throws IOException;
61
}
62