我现在正在使用一个程序,该程序向服务器发送消息/从服务器接收消息。
我在 ClassOne 中保护了名为 onNotice 的 void,当服务器发出“通知”(又名消息)时,它会从服务器获取参数:
onNotice(sourceNick, notice){}
我在 ClassTwo 中有一个方法可以触发 onNotice 的服务器响应:
noticeCheck(sender){
sendNotice("receiver", "sendNotice triggers server response" + sender);
}
//followed by next action
nextAction(){
if(noticeTrue){
doSomething;
return;
}
doSomethingElse;
}
如何在 ClassOne 中为 nextAction 创建 notificationTrue? nextAction 不应该必须等待 onNotice 接收服务器响应才能确定 notificationTrue 是 true 还是 false 吗?
非常感谢您的帮助
最佳答案
在noticeTrue处指定假值,并在onNotice时将值更改为true
关于java - 服务器响应设置 boolean 值 true/false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36557834/