From 9b02d379e754285d4ba0b8d315f860d2c0f8a098 Mon Sep 17 00:00:00 2001 From: Matthew Nguyen Date: Thu, 11 Apr 2024 18:50:03 +0000 Subject: [PATCH] Bug fixed and removed WebSocket.java --- src/main/java/com/cse3310/App.java | 50 +++++++++++++ .../cse3310/{Coordinate => Coordinate.java} | 5 +- src/main/java/com/cse3310/Game.Java | 39 ---------- src/main/java/com/cse3310/Game.java | 43 +++++++++++ src/main/java/com/cse3310/Locations.java | 6 +- .../java/com/cse3310/{User.Java => User.java} | 2 +- src/main/java/com/cse3310/UserEvent.java | 3 +- src/main/java/com/cse3310/WebSocket.java | 68 ------------------ target/classes/com/cse3310/App.class | Bin 0 -> 3313 bytes target/classes/com/cse3310/Coordinate.class | Bin 0 -> 572 bytes target/classes/com/cse3310/Game.class | Bin 0 -> 1369 bytes target/classes/com/cse3310/HttpServer$1.class | Bin 0 -> 1652 bytes target/classes/com/cse3310/HttpServer.class | Bin 0 -> 2389 bytes target/classes/com/cse3310/Locations.class | Bin 0 -> 825 bytes target/classes/com/cse3310/ServerEvent.class | Bin 0 -> 341 bytes target/classes/com/cse3310/User.class | Bin 0 -> 632 bytes target/classes/com/cse3310/UserEvent.class | Bin 0 -> 337 bytes .../compile/default-compile/inputFiles.lst | 4 ++ target/test-classes/com/cse3310/AppTest.class | Bin 0 -> 469 bytes 19 files changed, 105 insertions(+), 115 deletions(-) rename src/main/java/com/cse3310/{Coordinate => Coordinate.java} (60%) delete mode 100644 src/main/java/com/cse3310/Game.Java create mode 100644 src/main/java/com/cse3310/Game.java rename src/main/java/com/cse3310/{User.Java => User.java} (89%) delete mode 100644 src/main/java/com/cse3310/WebSocket.java create mode 100644 target/classes/com/cse3310/App.class create mode 100644 target/classes/com/cse3310/Coordinate.class create mode 100644 target/classes/com/cse3310/Game.class create mode 100644 target/classes/com/cse3310/HttpServer$1.class create mode 100644 target/classes/com/cse3310/HttpServer.class create mode 100644 target/classes/com/cse3310/Locations.class create mode 100644 target/classes/com/cse3310/ServerEvent.class create mode 100644 target/classes/com/cse3310/User.class create mode 100644 target/classes/com/cse3310/UserEvent.class create mode 100644 target/test-classes/com/cse3310/AppTest.class diff --git a/src/main/java/com/cse3310/App.java b/src/main/java/com/cse3310/App.java index e8cc71e..5ac9b21 100644 --- a/src/main/java/com/cse3310/App.java +++ b/src/main/java/com/cse3310/App.java @@ -37,6 +37,56 @@ public App(int port, Draft_6455 draft){ } + @Override + public void onOpen(WebSocket conn, ClientHandshake handshake) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'onOpen'"); + } + + @Override + public void onClose(WebSocket conn, int code, String reason, boolean remote) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'onClose'"); + } + + @Override + public void onMessage(WebSocket conn, String message) { + // TODO Auto-generated method stub + System.out.println(conn + ": " + message); // Log message in console + + // Bring in the data from the webpage + // A UserEvent is all that is allowed at this point + GsonBuilder builder = new GsonBuilder(); + Gson gson = builder.create(); + UserEvent U = gson.fromJson(message, UserEvent.class); + System.out.println(U.Button); + + // Get our Game Object + Game G = conn.getAttachment(); + G.Update(U); + + // send out the game state every time + // to everyone + String jsonString; + jsonString = gson.toJson(G); + + System.out.println(jsonString); + broadcast(jsonString); + throw new UnsupportedOperationException("Unimplemented method 'onMessage'"); + } + + @Override + public void onError(WebSocket conn, Exception ex) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'onError'"); + } + + @Override + public void onStart() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'onStart'"); + } + public static void main(String[] args) { diff --git a/src/main/java/com/cse3310/Coordinate b/src/main/java/com/cse3310/Coordinate.java similarity index 60% rename from src/main/java/com/cse3310/Coordinate rename to src/main/java/com/cse3310/Coordinate.java index 1f26f86..e052594 100644 --- a/src/main/java/com/cse3310/Coordinate +++ b/src/main/java/com/cse3310/Coordinate.java @@ -9,7 +9,8 @@ public void Coordinate(int x, int y){ this.y = y; } - public void getCoordinate(){ - return int[] location = new int[] {x, y}; + public int[] getCoordinate(){ + int[] location = new int[] {this.x, this.y}; + return location; } } \ No newline at end of file diff --git a/src/main/java/com/cse3310/Game.Java b/src/main/java/com/cse3310/Game.Java deleted file mode 100644 index 1c596c0..0000000 --- a/src/main/java/com/cse3310/Game.Java +++ /dev/null @@ -1,39 +0,0 @@ -package com.cse3310; - -import java.utils.ArrayList; - - -public class Game{ - private ArrayList User users; - public int GameId; - public int[][] grid; - - public Game() - { - - } - - public boolean checkVertical(array selectedLetters, int length){ - return true; - } - - public boolean checkDiagonal(array selectedLetters, int length){ - return true; - } - - public boolean checkHorizontal(array selectedLetters, int length){ - return true; - } - - public void checkWin(User user){ - - } - - public String keepScore(array){ - - } - - public void Tick(){ - - } -} \ No newline at end of file diff --git a/src/main/java/com/cse3310/Game.java b/src/main/java/com/cse3310/Game.java new file mode 100644 index 0000000..a160a11 --- /dev/null +++ b/src/main/java/com/cse3310/Game.java @@ -0,0 +1,43 @@ +package com.cse3310; + +import java.util.ArrayList; + +public class Game{ + private ArrayList users; + public int GameId; + public int[][] grid; + + public Game() + { + + } + + public boolean checkVertical(ArrayList selectedLetters, int length){ + return true; + } + + public boolean checkDiagonal(ArrayList selectedLetters, int length){ + return true; + } + + public boolean checkHorizontal(ArrayList selectedLetters, int length){ + return true; + } + + public void Update(UserEvent U){ + + } + + public void checkWin(User user){ + + } + + public String keepScore(ArrayList score){ + + return ""; + } + + public void Tick(){ + + } +} \ No newline at end of file diff --git a/src/main/java/com/cse3310/Locations.java b/src/main/java/com/cse3310/Locations.java index c3a0ff1..2ef60bd 100644 --- a/src/main/java/com/cse3310/Locations.java +++ b/src/main/java/com/cse3310/Locations.java @@ -3,13 +3,13 @@ import java.util.HashMap; class Locations { - static HashMap locationMap; + public HashMap locationMap; public int[] getStart(String s){ - return (locationMap.get(s)[0]).getCoordinate; + return (locationMap.get(s)[0]).getCoordinate(); } public int[] getEnd(String s){ - return (locationMap.get(s)[1]).getCoordinate; + return (locationMap.get(s)[1]).getCoordinate(); } } \ No newline at end of file diff --git a/src/main/java/com/cse3310/User.Java b/src/main/java/com/cse3310/User.java similarity index 89% rename from src/main/java/com/cse3310/User.Java rename to src/main/java/com/cse3310/User.java index 199ae19..ffc3d78 100644 --- a/src/main/java/com/cse3310/User.Java +++ b/src/main/java/com/cse3310/User.java @@ -14,7 +14,7 @@ public User(String username) this.gameWon = 0; } - public void setName(string newUsername){ + public void setName(String newUsername){ this.username = newUsername; diff --git a/src/main/java/com/cse3310/UserEvent.java b/src/main/java/com/cse3310/UserEvent.java index a208c98..707d907 100644 --- a/src/main/java/com/cse3310/UserEvent.java +++ b/src/main/java/com/cse3310/UserEvent.java @@ -2,7 +2,6 @@ public class UserEvent { int GameId; - User UserId; + int UserId; int Button[][]; - String message; } diff --git a/src/main/java/com/cse3310/WebSocket.java b/src/main/java/com/cse3310/WebSocket.java deleted file mode 100644 index 5fd93b3..0000000 --- a/src/main/java/com/cse3310/WebSocket.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.cse3310; - -import org.java_websocket.WebSocket; -import org.java_websocket.drafts.Draft; -import org.java_websocket.drafts.Draft_6455; -import org.java_websocket.handshake.ClientHandshake; -import org.java_websocket.server.WebSocketServer; -import java.util.Timer; -import java.util.TimerTask; -import java.util.Vector; - -public class WebSocket -{ - int port; - Connection con; - - @Override - public void onOpen(Connection conn, ClientHandshake handshake) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'onOpen'"); - } - - @Override - public void onClose(Connection conn, int code, String reason, boolean remote) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'onClose'"); - } - - @Override - public void onMessage(Connection conn, String message) { - // TODO Auto-generated method stub - System.out.println(conn + ": " + message); // Log message in console - - // Bring in the data from the webpage - // A UserEvent is all that is allowed at this point - GsonBuilder builder = new GsonBuilder(); - Gson gson = builder.create(); - UserEvent U = gson.fromJson(message, UserEvent.class); - System.out.println(U.Button); - - // Get our Game Object - Game G = conn.getAttachment(); - G.Update(U); - - // send out the game state every time - // to everyone - String jsonString; - jsonString = gson.toJson(G); - - System.out.println(jsonString); - broadcast(jsonString); - throw new UnsupportedOperationException("Unimplemented method 'onMessage'"); - } - - @Override - public void onError(Connection conn, Exception ex) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'onError'"); - } - - @Override - public void onStart() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'onStart'"); - } - - -} \ No newline at end of file diff --git a/target/classes/com/cse3310/App.class b/target/classes/com/cse3310/App.class new file mode 100644 index 0000000000000000000000000000000000000000..f367054c2308f4863ccba9af45ea9c243d6d040d GIT binary patch literal 3313 zcmb7G`BxKH6#gCrCd4R+E3VW90w~cU+7g!nB1REZAXc&3Niu}NWG0LXnV4Xpw#EAJ0sGn$(quq})RG&15b(=x`3xuoGt>B%g8 zY8|svdN!durkwkW0e8-1K%19&M}p{DAa6Ua!2XCAi$!+g96VkI(`m;j6k^g%P4^}O zd!BSupgR&DtHF8N(P!O4^t}AJd-6nozd~(L%aY2cG9i1mHIX+gfr&^hlZvFVTDx<) zl`hQb_l)Rp)-){l;^LgXXgDO$sTj}dRwg=a6^eODj*;etj_#VaHS!>3NSJgL z#|3(89j@%J3XHEc?kD(Ft;QHohic^pG8*o?_9 zo@y+$o3mXW6So+YZCzn<=^4)Z*70n$V_k_R4B)f|=CD^M-c=6^u8|Al3|L_Gc9E&Q z%`-Ob=v5N$l72(a#WcJiuwzMXPnDsfnN1r`2`r?|hh85TgQh1MLzjE}<^1Kv>L$H4&ucSQu9@E)aBW@4Ud)$m&aDAza0E4c7#= zsJNC#9LA(fMJ+E$$XXhv1$N7Bm9gzi)`(^(TXd8|g@Y-{!4zH$<0hzAV~WH{@pkg^ zT88BGHtDYJfYa=>BPG^H2zT(ZhP!mVmT4F|l8kWHv2&MH{+y~N+NY_CrQxhD`%=}4 zFGdq)kPgGZEIl47x~@#d`k9%yWM@v2V6LdgMHLepa1S{RS$4P@&8Sk3VOX#QHf9WW z&~^3HoUH$qlK7w+USWDxGa{b^A>>gA!$pxkPUq8#)m@Qg-MPXX8-*nAei#q%kmp_7 zBdDXApv4%f`0zOk@oDi|7_Uq1o05*Lr&D^t4dP9K_O)u-FH2Un#s{HSp<2=_4Ys|S z;xDE=JAuq3f$cSqv04QaZ^s(3a+ej;x@=cHMFm3hgk8*k_Oublu^oYvPv1Ez-J6sK z@%a;)n!;xIb;g5A|4{8^2}1SNNmqBskLR{1Qw-;Z`iB*@+Y|Bj3P9iasryxDsA5jy|o zjUFSCRiLK|HB>|X&k|WG7UDbZ z2^CWa{W!^31y12P?i#V`gjjv-8Al$|V&SzJOEmsRxFJUQ?)Xz{ zFrEoFB+wI|KA&eo^1}1I@RFdkJ41rn3noH`0>eNW8A8GKd~v;AjK%WK8P5fwWCyM@ zA394<&hb(WAG{TzZvUU;oS^S=5wv!{-x+2=s2I?YlwHk03Q0n4D#E{5wcWYru<1G5 zhF;(k5^~mWgZ0uCSDwsN*bz?Td(mP+h5t~3E9-MdQk|>Z^2>PExwE(uSIvA!_LZ9i za(pMFrGh;7#uk7AiaZhaP~uyXZx}7*vSwq0vf13Ax|7JqP8xgZ{7I?S79LA6G0GJcW#q4JSOZOe&0N<1ClkQE7y Hh|~N9GVN99 literal 0 HcmV?d00001 diff --git a/target/classes/com/cse3310/Game.class b/target/classes/com/cse3310/Game.class new file mode 100644 index 0000000000000000000000000000000000000000..35d813036a980501bbb97d76e70cc68a8b5e6233 GIT binary patch literal 1369 zcmbtSTW=CU6#j-?u2MnlU8}8H1!{|i7$0bw7_THm6DgS3r)8PI6xeN+p-KHsKIoH) z5B>mul<}Nd#8PQY(}$foXU^I0`_AR(ukSwql(7>>L?G+>gOWRxyn%`i|Ery=xsxR|`Z(Lm3PO7HTFo(yCv276i^oO$~KLAX!%(&(Whm3KVAL?AA_G zH3+S;NB_l`wAvOBRROybC^D^s19D=!%2Rre+2-8hU~yXK$G&S&$ryca{6Ky3JaK4lJ+mp5 z@dB6ys_Q^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7FGlr>z} z(~O-qk;EQ>)|}(X=}Ku)26OhJ%QU2Ne!+J0cHroF{bO7$JE6eg-1holx(&?(9n~^A z9c6SE^B<@L&XW|!i&!ge&=xHjpryGH@tET>yTc%x!?3tWZIZ=gFBrHi zaCEc5w6DheidVe4T99Ss_?|YtV&bZ%t#wJNON*iJR+OBv)p8P-kTx(OaMF{?x*bSa zQH~o@ma1IKr!_G*H&au6661JNC-p5#kD1Er4^t+laZO+^UFV%ZRcv>{52>oF+oe6X zgJZfjxnUyT#;k$s0@nXDH8F>GSUe#iyRLt4TzWFFl`KwrMY*aGEcE0Pc$Z~o8JHJ1 zx03^OPFToFuBr*!E4ngB;s$PNR&ELGuVbd%^v02%yn*){%P(pN8r6p;Y%B^S?P9U+ zQQ+1#r0s~a#+XKKZmA;1k^oiHY}sYUQcg)4xJ?CbFW|1hBqWwKEJvU-^ItlzY2dDj zSCC48VoyJlOWFz3uETEQ=@#L8wa%cMl5e6MwI3Oc~&!&pKg8r9NwnY-EN_r>1X#?wt_Kx{NPJx*pug_67}8VeBLI zF54I#-L}jsyKr~PF4tR2a@MZ|1*!GJf_--94CpFncbN33<5AZRLm3+QR^ZG|bla#8 z(((L<)K+B+?AcU`IL$sos$$YC2@?B^i|kj6oD zQ$krB!WpioYp!`=pXCf}`!6#T5xt$Gtqz6Stc4=3Fz`6n9x{N`t2}ZY!}Hl+(6)vP zx!x*Xdx+L`T$<yYzAxK#hrSH+zTm@Z*zH&2oNjE>x6co7F5agpbRH4Yvz(geQ1*H|Gk&A>2;)I20` zg!qs05oW}`V#7WGsWERnf+vun503N`?Pqfwyoh4=>t}}E1cd?55JY@(u ze2h=X(0PpEQ>H0KyLNm|4+3A(rX8`raLT~&KUjb;_?5#-J1xHAY7=98z~>1vD*4pE XZ+Ibm$NwES`1~Ht>~iDy0nPscBC}~F literal 0 HcmV?d00001 diff --git a/target/classes/com/cse3310/Locations.class b/target/classes/com/cse3310/Locations.class new file mode 100644 index 0000000000000000000000000000000000000000..a69f779d792e5331fd9045c36e801b03851c2fdf GIT binary patch literal 825 zcmaiyPfrt36vfYN3qyw~P>>@2MFnj!VbCs1hzY@HQguf}Im zLpEJZ*9Z?)V$yRimh7<^2v+`Sb+s@1%=ESGSe0O=w_9^fITB~I{ioHPot)fj{4l7q*B)&Iue;whdvSmR_j2j$^8UI;4ed7U1!s&i_A zaPP&jrg`d&mj3;yCvZFQFbVW~lg2l9mC9DS9M-sYk$((9>F%r!PX)|mD!&1hSt@?! z0H!v7!TXU}=2+7U6fw{0iPcp`~r~RAb=xqsLNdHijw5=LN3U*WN%w4>Hw}lyjHD}nJQl8W4b0? z3-~W(GqohJHy^%yuE<{T^j_sOTM396lWS9$dLl47Ib904H|2^#jIbSH6QRI(ZVGy6 z@|5h8O0(Xx)GAvlYdZcXy7il>1djgg8zkkm;i7D;raRM_#Dm#+cL0vT8Te+0s|TMu sAixGA2ko*jZZVTR2fVWnMDHv(*kSZp1{;hSqrUeLW0x8K0;7ZdU*_#am;e9( literal 0 HcmV?d00001 diff --git a/target/classes/com/cse3310/User.class b/target/classes/com/cse3310/User.class new file mode 100644 index 0000000000000000000000000000000000000000..d376a46bd45cfbdb2e5f0ecfa0a236b632b073c5 GIT binary patch literal 632 zcmZWm%TB^T6g@*rOQ8tz^8MNYCRW2z!-mAfgx~^2x1~&K3A9ODlN9ohQn4Eee;LqQy+SE?sap|e6JKvM=c?jX2nt*s29GoL&ES{rRAjHhQaf`3~rRD=$CF(T{{`k6NBu`P2| zzlgk0gke@mQOrcG9dAwFzUzi?oc)_{Oo*PVwwCH%yA{2^>=!OJPQd^3ovykFSb=cc scd*OEN4Pw!F;lW(o<0A>{s$W#`m6!lZpnZ(-n_dwz>tY>$m-$f7b?y`%m4rY literal 0 HcmV?d00001 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 2c5c587..5f81ea2 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,5 +1,9 @@ +/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/Game.java /workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/HttpServer.java +/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/Coordinate.java /workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/ServerEvent.java /workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/UserEvent.java +/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/User.java +/workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/Locations.java /workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/App.java /workspaces/cse3310_sp24_group_26/src/main/java/com/cse3310/WebSocket.java diff --git a/target/test-classes/com/cse3310/AppTest.class b/target/test-classes/com/cse3310/AppTest.class new file mode 100644 index 0000000000000000000000000000000000000000..35d03406e449d8b7158635003417c54de54d8daf GIT binary patch literal 469 zcmZvY%}&BV6ot=}LbX;wepHt3(1pcxi7{zRTs4{~!NlEACNQMTkj_+}%az8358y)? zZ-Imjn|tTXx%p zFm#d~PY)Q{W~Pg55-amA@)v1m!@M9=_o+};F2qP0Nvv2YZMl_N5vq~sd>YOR`dwHC z82D(S?V&~1)`^V~xed_434_m9YRz_guVoUK?q&J)V6%*?at}BMrKYt34xK11 zRgY9iol&n|eq!%qW&2c18}M;JHCPW&KP1I)M6QGSW~xEG1V!YmK<*cgw;-QJL1A39 LcEV1{b#V3%5Kdgd literal 0 HcmV?d00001