Skip to content

Commit df44664

Browse files
committed
added changes missing in the previous commit
1 parent 06b9a1c commit df44664

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

src/client/Client.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import java.rmi.registry.LocateRegistry
55
import java.util.Calendar
66
import scala.annotation.tailrec
77
import scala.language.postfixOps
8+
import java.rmi.server.UnicastRemoteObject
89

910
sealed abstract class State
1011
object State {
@@ -32,6 +33,8 @@ object Client {
3233
val ret = stub login(user,pass)
3334
if (ret) {
3435
println("Welcome back! :D")
36+
val callback: ClientTrait = new ClientTraitImpl(user)
37+
stub registerForCallback(user,callback)
3538
(MainState,user)
3639
}
3740
else {
@@ -334,7 +337,7 @@ Message: ${tweet.msg}""")
334337
val registry = LocateRegistry getRegistry("localhost")
335338
val stub = registry.lookup("tweetorro").asInstanceOf[server.ServerTrait]
336339

337-
stub.test(Test(n => println(n)))
340+
//stub.test(Test(n => println(n)))
338341
println("Welcome to Tweetorro terminal App!")
339342
repl(stub,(StartState,""))
340343
} catch {

src/client/ClientTrait.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ package client
33
import java.rmi.Remote
44
import java.rmi.RemoteException
55

6-
trait ClientTrait extends Remote { }
6+
trait ClientTrait extends Remote {
7+
8+
@throws(classOf[RemoteException])
9+
def notifyMe(): Unit
10+
11+
@throws(classOf[RemoteException])
12+
def getUserName():String
13+
}

src/server/ServerTrait.scala

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,69 @@
1-
/home/yagox//git/Tweetorro/src/server/ServerTrait.scala
1+
package server
2+
3+
import java.rmi.Remote
4+
import java.rmi.RemoteException
5+
import client.ClientTrait
6+
7+
object Shared {
8+
case class DMTweet(user: String, msg: String, date: String)
9+
case class DMT(id: String, user: String, msg: String, date: String)
10+
case class Test(f: Int => Unit)
11+
}
12+
13+
trait ServerTrait extends Remote {
14+
import Shared._
15+
16+
@throws(classOf[RemoteException])
17+
def registerForCallback(userName: String,callback: ClientTrait): Unit
18+
19+
@throws(classOf[RemoteException])
20+
def searchUsers(name: String): List[String]
21+
22+
@throws(classOf[RemoteException])
23+
def sendDM(dm: DMTweet, userTo: String): Unit
24+
25+
@throws(classOf[RemoteException])
26+
def getDM(user: String, number: Int): List[DMT]
27+
28+
@throws(classOf[RemoteException])
29+
def createUser(user: String, pass: String): Boolean
30+
31+
@throws(classOf[RemoteException])
32+
def login(user: String, pass: String): Boolean
33+
34+
@throws(classOf[RemoteException])
35+
def sendTweet(tweet: DMTweet): Unit
36+
37+
@throws(classOf[RemoteException])
38+
def retweet(user: String, tweetID: String): Boolean
39+
40+
@throws(classOf[RemoteException])
41+
def follow(user: String, userID: String): Boolean
42+
43+
@throws(classOf[RemoteException])
44+
def unfollow(user: String, userID: String): Boolean
45+
46+
@throws(classOf[RemoteException])
47+
def followers(user: String, number: Int): List[String]
48+
49+
@throws(classOf[RemoteException])
50+
def following(user: String, number: Int): List[String]
51+
52+
@throws(classOf[RemoteException])
53+
def logoutRemote(user: String): Boolean
54+
55+
@throws(classOf[RemoteException])
56+
def checkRemoteProfile(user: String, param: String): Option[String]
57+
58+
@throws(classOf[RemoteException])
59+
def modifyRemoteProfile(user: String, param: String, value: String): Boolean
60+
61+
@throws(classOf[RemoteException])
62+
def getTweets(user: String, number: Int): List[DMT]
63+
64+
@throws(classOf[RemoteException])
65+
def test(f: Test): Unit
66+
}
67+
68+
69+

0 commit comments

Comments
 (0)