Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
p2-public
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cse332-24wi
p2-public
Commits
fe070f8a
Commit
fe070f8a
authored
3 years ago
by
WinJ
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
618a2787
6e9e5ee2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build.gradle
+1
-0
1 addition, 0 deletions
build.gradle
src/main/java/chat/UMessageServerConnection.java
+48
-29
48 additions, 29 deletions
src/main/java/chat/UMessageServerConnection.java
with
49 additions
and
29 deletions
build.gradle
+
1
−
0
View file @
fe070f8a
...
...
@@ -25,6 +25,7 @@ dependencies {
test
{
useJUnitPlatform
()
maxHeapSize
=
"4096m"
}
java
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/chat/UMessageServerConnection.java
+
48
−
29
View file @
fe070f8a
package
chat
;
import
javax.swing.*
;
import
java.io.*
;
import
java.net.Socket
;
import
java.net.UnknownHostException
;
...
...
@@ -72,12 +73,12 @@ public class UMessageServerConnection extends Thread {
try
{
cmd
=
cmd
.
trim
();
switch
(
cmd
)
{
case
"MAIN"
:
m_channel
(
UMessageServerConnection
.
CHAT_CHANNEL
,
text
);
break
;
default
:
String
[]
parts
=
text
.
split
(
" "
,
2
);
cmd
=
parts
[
0
].
trim
();
case
"MAIN"
:
m_channel
(
UMessageServerConnection
.
CHAT_CHANNEL
,
text
);
break
;
default
:
String
[]
parts
=
text
.
split
(
" "
,
2
);
cmd
=
parts
[
0
].
trim
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -112,34 +113,52 @@ public class UMessageServerConnection extends Thread {
while
((
line
=
this
.
in
.
readLine
())
!=
null
)
{
if
(
line
.
startsWith
(
"PING"
))
{
write
(
"PONG"
,
line
.
substring
(
5
));
}
else
if
(
line
.
startsWith
(
":umessage"
))
{
}
else
if
(
line
.
split
(
" "
)[
1
].
trim
().
equals
(
"353"
))
{
int
code
=
Integer
.
parseInt
(
line
.
split
(
" "
)[
1
]);
switch
(
code
)
{
// List of users...
case
IRCCodes
.
RplNamReply
:
String
[]
names
=
line
.
split
(
":"
)[
2
].
split
(
" "
);
this
.
main
.
window
.
addUsers
(
names
);
break
;
// List of users...
case
IRCCodes
.
RplNamReply
:
String
[]
names
=
line
.
split
(
":"
)[
2
].
split
(
" "
);
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
main
.
window
.
addUsers
(
names
);
}
});
break
;
}
}
else
{
}
else
{
String
cmd
=
line
.
split
(
" "
)[
1
];
final
String
[]
lineParts
=
line
.
split
(
":"
);
switch
(
cmd
)
{
case
"PART"
:
this
.
main
.
window
.
removeUser
(
line
.
split
(
":"
)[
1
].
split
(
"!"
)[
0
]);
break
;
case
"JOIN"
:
this
.
main
.
window
.
addUser
(
line
.
split
(
":"
)[
1
].
split
(
"!"
)[
0
]);
break
;
case
"PRIVMSG"
:
if
(!
line
.
split
(
" "
)[
2
].
equals
(
this
.
username
))
{
return
;
}
String
[]
lineParts
=
line
.
split
(
":"
);
this
.
main
.
window
.
gotMessage
(
lineParts
[
1
].
split
(
"!"
)[
0
],
lineParts
[
2
]);
break
;
case
"PART"
:
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
main
.
window
.
removeUser
(
lineParts
[
1
].
split
(
"!"
)[
0
]);
}
});
break
;
case
"JOIN"
:
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
main
.
window
.
addUser
(
lineParts
[
1
].
split
(
"!"
)[
0
]);
}
});
break
;
case
"PRIVMSG"
:
if
(!
line
.
split
(
" "
)[
2
].
equals
(
this
.
username
))
{
return
;
}
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
main
.
window
.
gotMessage
(
lineParts
[
1
].
split
(
"!"
)[
0
],
lineParts
[
2
]);
}
});
break
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment