Kaynağa Gözat

Add some more server events.

Change-Id: Ib12542d236757d76540d57ff54341e3b73ceb598
Reviewed-on: http://gerrit.dmdirc.com/3437
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
pull/1/head
Greg Holmes 10 yıl önce
ebeveyn
işleme
5bf9e9b3ec

+ 13
- 12
src/com/dmdirc/Server.java Dosyayı Görüntüle

@@ -28,6 +28,11 @@ import com.dmdirc.actions.CoreActionType;
28 28
 import com.dmdirc.commandparser.CommandType;
29 29
 import com.dmdirc.commandparser.parsers.CommandParser;
30 30
 import com.dmdirc.events.ChannelOpenedEvent;
31
+import com.dmdirc.events.ServerConnectErrorEvent;
32
+import com.dmdirc.events.ServerConnectedEvent;
33
+import com.dmdirc.events.ServerConnectingEvent;
34
+import com.dmdirc.events.ServerDisconnectedEvent;
35
+import com.dmdirc.events.ServerNumericEvent;
31 36
 import com.dmdirc.interfaces.AwayStateListener;
32 37
 import com.dmdirc.interfaces.Connection;
33 38
 import com.dmdirc.interfaces.InviteListener;
@@ -371,8 +376,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
371 376
             }
372 377
         }
373 378
 
374
-        ActionManager.getActionManager().triggerEvent(
375
-                CoreActionType.SERVER_CONNECTING, null, this);
379
+        eventBus.post(new ServerConnectingEvent(this));
376 380
     }
377 381
 
378 382
     @Override
@@ -1192,10 +1196,11 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1192 1196
             target = new StringBuffer("numeric_unknown");
1193 1197
         }
1194 1198
 
1195
-        ActionManager.getActionManager().triggerEvent(
1196
-                CoreActionType.SERVER_NUMERIC, target, this, numeric, tokens);
1199
+        final ServerNumericEvent event = new ServerNumericEvent(this, numeric, tokens);
1200
+        event.setDisplayFormat(target.toString());
1201
+        eventBus.post(event);
1197 1202
 
1198
-        handleNotification(target.toString(), (Object[]) tokens);
1203
+        handleNotification(event.getDisplayFormat(), (Object[]) tokens);
1199 1204
     }
1200 1205
 
1201 1206
     /**
@@ -1222,8 +1227,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1222 1227
 
1223 1228
         handleNotification("socketClosed", getAddress());
1224 1229
 
1225
-        ActionManager.getActionManager().triggerEvent(
1226
-                CoreActionType.SERVER_DISCONNECTED, null, this);
1230
+        eventBus.post(new ServerDisconnectedEvent(this));
1227 1231
 
1228 1232
         eventHandler.unregisterCallbacks();
1229 1233
 
@@ -1330,9 +1334,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1330 1334
                 }
1331 1335
             }
1332 1336
 
1333
-            ActionManager.getActionManager().triggerEvent(
1334
-                    CoreActionType.SERVER_CONNECTERROR, null, this,
1335
-                    description);
1337
+            eventBus.post(new ServerConnectErrorEvent(this, description));
1336 1338
 
1337 1339
             handleNotification("connectError", getAddress(), description);
1338 1340
 
@@ -1413,8 +1415,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
1413 1415
             }, whoTime, whoTime, TimeUnit.MILLISECONDS);
1414 1416
         }
1415 1417
 
1416
-        ActionManager.getActionManager().triggerEvent(
1417
-                CoreActionType.SERVER_CONNECTED, null, this);
1418
+        eventBus.post(new ServerConnectedEvent(this));
1418 1419
     }
1419 1420
 
1420 1421
     /**

+ 1
- 1
src/com/dmdirc/actions/ActionManager.java Dosyayı Görüntüle

@@ -182,7 +182,7 @@ public class ActionManager implements ActionController {
182 182
             addGroup(wrapper);
183 183
         }
184 184
 
185
-        new WhoisNumericFormatter(identityManager.getAddonSettings()).register();
185
+        new WhoisNumericFormatter(identityManager.getAddonSettings(), eventBus).register();
186 186
 
187 187
         eventBus.register(this);
188 188
     }

+ 5
- 0
src/com/dmdirc/actions/CoreActionType.java Dosyayı Görüntüle

@@ -85,14 +85,19 @@ public enum CoreActionType implements ActionType {
85 85
     /** Unknown command. */
86 86
     UNKNOWN_COMMAND(ClientEvents.UNKNOWN_COMMAND, "Unknown command entered"),
87 87
     /** Server numeric received. */
88
+    @Deprecated
88 89
     SERVER_NUMERIC(ServerEvents.SERVER_NUMERIC, "Numeric event received"),
89 90
     /** Server connected. */
91
+    @Deprecated
90 92
     SERVER_CONNECTED(ServerEvents.SERVER_EVENT, "Server connected"),
91 93
     /** Server connecting. */
94
+    @Deprecated
92 95
     SERVER_CONNECTING(ServerEvents.SERVER_EVENT, "Server connecting"),
93 96
     /** Server connection error. */
97
+    @Deprecated
94 98
     SERVER_CONNECTERROR(ServerEvents.SERVER_EVENT_WITH_ARG, "Server connection error"),
95 99
     /** Server disconnected. */
100
+    @Deprecated
96 101
     SERVER_DISCONNECTED(ServerEvents.SERVER_EVENT, "Server disconnected"),
97 102
     /** Marked as away. */
98 103
     SERVER_BACK(ServerEvents.SERVER_EVENT, "Marked as 'back'"),

+ 26
- 32
src/com/dmdirc/actions/internal/WhoisNumericFormatter.java Dosyayı Görüntüle

@@ -22,13 +22,14 @@
22 22
 
23 23
 package com.dmdirc.actions.internal;
24 24
 
25
-import com.dmdirc.actions.ActionManager;
26
-import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.interfaces.ActionListener;
25
+import com.dmdirc.events.ServerDisconnectedEvent;
26
+import com.dmdirc.events.ServerNumericEvent;
28 27
 import com.dmdirc.interfaces.Connection;
29
-import com.dmdirc.interfaces.actions.ActionType;
30 28
 import com.dmdirc.interfaces.config.ConfigProvider;
31 29
 
30
+import com.google.common.eventbus.EventBus;
31
+import com.google.common.eventbus.Subscribe;
32
+
32 33
 import java.util.HashMap;
33 34
 import java.util.Map;
34 35
 
@@ -37,51 +38,44 @@ import java.util.Map;
37 38
  *
38 39
  * @since 0.6.3
39 40
  */
40
-public class WhoisNumericFormatter implements ActionListener {
41
+public class WhoisNumericFormatter {
41 42
 
42 43
     /** The name of the target of any current whois requests. */
43 44
     private final Map<Connection, String> targets = new HashMap<>();
44 45
     /** The identity to add formatters to. */
45 46
     private final ConfigProvider identity;
47
+    /** Event bus to subscribe to events on. */
48
+    private final EventBus eventBus;
46 49
 
47 50
     /**
48 51
      * Creates a new whois numeric formatter that will add automatic formats to the specified
49 52
      * identity. This will normally be a temporary global identity.
50 53
      *
51 54
      * @param identity The identity to write formatters to
55
+     * @param eventBus The event bus to subscribe to events on
52 56
      */
53
-    public WhoisNumericFormatter(final ConfigProvider identity) {
57
+    public WhoisNumericFormatter(final ConfigProvider identity,
58
+            final EventBus eventBus) {
54 59
         this.identity = identity;
60
+        this.eventBus = eventBus;
55 61
     }
56 62
 
57 63
     /**
58 64
      * Registers this this whois numeric formatter with the global actions manager.
59 65
      */
60 66
     public void register() {
61
-        ActionManager.getActionManager().registerListener(this,
62
-                CoreActionType.SERVER_NUMERIC,
63
-                CoreActionType.SERVER_DISCONNECTED);
64
-    }
65
-
66
-    @Override
67
-    public void processEvent(final ActionType type, final StringBuffer format,
68
-            final Object... arguments) {
69
-        if (CoreActionType.SERVER_DISCONNECTED == type) {
70
-            handleServerDisconnected((Connection) arguments[0]);
71
-        } else {
72
-            handleNumeric((Connection) arguments[0], (Integer) arguments[1],
73
-                    (String[]) arguments[2], format);
74
-        }
67
+        eventBus.register(this);
75 68
     }
76 69
 
77 70
     /**
78 71
      * Handles a server disconnected event. This clears any entry for that server in the
79 72
      * {@link #targets} map.
80 73
      *
81
-     * @param server The server that was disconnected
74
+     * @param event The server disconnected event to process
82 75
      */
83
-    private void handleServerDisconnected(final Connection server) {
84
-        targets.remove(server);
76
+    @Subscribe
77
+    public void handleServerDisconnected(final ServerDisconnectedEvent event) {
78
+        targets.remove(event.getConnection());
85 79
     }
86 80
 
87 81
     /**
@@ -90,13 +84,13 @@ public class WhoisNumericFormatter implements ActionListener {
90 84
      * without formatters for events which look like WHOIS information, and formats them
91 85
      * automatically.
92 86
      *
93
-     * @param server    The server on which the event was received
94
-     * @param numeric   The numeric code of the event
95
-     * @param arguments The arguments to the numeric event
96
-     * @param format    The format that should be used to display the event
87
+     * @param event The server numeric event to process
97 88
      */
98
-    private void handleNumeric(final Connection server, final int numeric,
99
-            final String[] arguments, final StringBuffer format) {
89
+    @Subscribe
90
+    public void handleNumeric(final ServerNumericEvent event) {
91
+        final Connection server = event.getConnection();
92
+        final int numeric = event.getNumeric();
93
+        final String[] arguments = event.getArgs();
100 94
         switch (numeric) {
101 95
             case 311: // RPL_WHOISUSER
102 96
                 targets.put(server, arguments[3]);
@@ -110,17 +104,17 @@ public class WhoisNumericFormatter implements ActionListener {
110 104
                         && arguments[3].equals(targets.get(server))) {
111 105
                     // This numeric should be automatically formatted.
112 106
 
113
-                    if (format.length() > 0) {
107
+                    if (!event.getDisplayFormat().isEmpty()) {
114 108
                         // There's a custom format. We'll see if we need to
115 109
                         // add a formatter or notification settings for it
116 110
                         // anyway.
117
-                        ensureExists(format.toString(), arguments.length);
111
+                        ensureExists(event.getDisplayFormat(), arguments.length);
118 112
                     } else {
119 113
                         // No custom formatter, switch it to an auto whois
120 114
                         // format and target.
121 115
                         final String target = "numeric_autowhois_" + (arguments.length - 4);
122 116
                         ensureExists(target, arguments.length);
123
-                        format.replace(0, format.length(), target);
117
+                        event.setDisplayFormat(target);
124 118
                     }
125 119
                 }
126 120
                 break;

+ 49
- 0
src/com/dmdirc/events/ServerConnectErrorEvent.java Dosyayı Görüntüle

@@ -0,0 +1,49 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.Connection;
26
+
27
+/**
28
+ * Fire when a server errored whilst connecting.
29
+ */
30
+public class ServerConnectErrorEvent extends ServerEvent {
31
+
32
+    private final String message;
33
+
34
+    public ServerConnectErrorEvent(final Connection connection, final String message) {
35
+        super(connection);
36
+        this.message = message;
37
+    }
38
+
39
+    public ServerConnectErrorEvent(final long timestamp, final Connection connection,
40
+            final String message) {
41
+        super(timestamp, connection);
42
+        this.message = message;
43
+    }
44
+
45
+    public String getMessage() {
46
+        return message;
47
+    }
48
+
49
+}

+ 40
- 0
src/com/dmdirc/events/ServerConnectedEvent.java Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.Connection;
26
+
27
+/**
28
+ * Fire when a server is connected.
29
+ */
30
+public class ServerConnectedEvent extends ServerEvent {
31
+
32
+    public ServerConnectedEvent(final Connection connection) {
33
+        super(connection);
34
+    }
35
+
36
+    public ServerConnectedEvent(final long timestamp, final Connection connection) {
37
+        super(timestamp, connection);
38
+    }
39
+
40
+}

+ 40
- 0
src/com/dmdirc/events/ServerConnectingEvent.java Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.Connection;
26
+
27
+/**
28
+ * Fire when a server is connecting.
29
+ */
30
+public class ServerConnectingEvent extends ServerEvent {
31
+
32
+    public ServerConnectingEvent(final Connection connection) {
33
+        super(connection);
34
+    }
35
+
36
+    public ServerConnectingEvent(final long timestamp, final Connection connection) {
37
+        super(timestamp, connection);
38
+    }
39
+
40
+}

+ 40
- 0
src/com/dmdirc/events/ServerDisconnectedEvent.java Dosyayı Görüntüle

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.Connection;
26
+
27
+/**
28
+ * Fire when a server disconnects.
29
+ */
30
+public class ServerDisconnectedEvent extends ServerEvent {
31
+
32
+    public ServerDisconnectedEvent(final Connection connection) {
33
+        super(connection);
34
+    }
35
+
36
+    public ServerDisconnectedEvent(final long timestamp, final Connection connection) {
37
+        super(timestamp, connection);
38
+    }
39
+
40
+}

+ 55
- 0
src/com/dmdirc/events/ServerDisplayableEvent.java Dosyayı Görüntüle

@@ -0,0 +1,55 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.Connection;
26
+
27
+import java.util.concurrent.atomic.AtomicReference;
28
+
29
+
30
+/**
31
+ * Base type for events that occur on a connection.
32
+ */
33
+public abstract class ServerDisplayableEvent extends ServerEvent implements DisplayableEvent {
34
+
35
+    /** The display format to use for this event. */
36
+    private final AtomicReference<String> displayFormatRef = new AtomicReference<>("");
37
+
38
+    public ServerDisplayableEvent(final long timestamp, final Connection connection) {
39
+        super(timestamp, connection);
40
+    }
41
+
42
+    public ServerDisplayableEvent(final Connection connection) {
43
+        super(connection);
44
+    }
45
+
46
+    @Override
47
+    public String getDisplayFormat() {
48
+        return displayFormatRef.get();
49
+    }
50
+
51
+    @Override
52
+    public void setDisplayFormat(String format) {
53
+        this.displayFormatRef.set(format);
54
+    }
55
+}

+ 50
- 0
src/com/dmdirc/events/ServerEvent.java Dosyayı Görüntüle

@@ -0,0 +1,50 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.interfaces.Connection;
26
+
27
+import static com.google.common.base.Preconditions.checkNotNull;
28
+
29
+/**
30
+ * Base type for events that occur on a connection.
31
+ */
32
+public abstract class ServerEvent extends DMDircEvent {
33
+
34
+    /** The connection that this event occurred on. */
35
+    private final Connection connection;
36
+
37
+    public ServerEvent(final long timestamp, final Connection connection) {
38
+        super(timestamp);
39
+        this.connection = checkNotNull(connection);
40
+    }
41
+
42
+    public ServerEvent(final Connection connection) {
43
+        this.connection = checkNotNull(connection);
44
+    }
45
+
46
+    public Connection getConnection() {
47
+        return connection;
48
+    }
49
+
50
+}

+ 56
- 0
src/com/dmdirc/events/ServerNumericEvent.java Dosyayı Görüntüle

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.Server;
26
+
27
+/**
28
+ * Event raised when a server numeric occurs.
29
+ */
30
+public class ServerNumericEvent extends ServerDisplayableEvent {
31
+
32
+    private final int numeric;
33
+    private final String[] args;
34
+
35
+    public ServerNumericEvent(final long timestamp, final Server server, final int numeric,
36
+            final String[] args) {
37
+        super(timestamp, server);
38
+        this.numeric = numeric;
39
+        this.args = args;
40
+    }
41
+
42
+    public ServerNumericEvent(final Server server, final int numeric, final String[] args) {
43
+        super(server);
44
+        this.numeric = numeric;
45
+        this.args = args;
46
+    }
47
+
48
+    public int getNumeric() {
49
+        return numeric;
50
+    }
51
+
52
+    public String[] getArgs() {
53
+        return args;
54
+    }
55
+
56
+}

Loading…
İptal
Kaydet