السلا م عليكم ورحمة الله
عندي شبكة مكونة مع حاسب ادمن ومجموعة حواسيب متصلن عبر شبكة
اريد ايجاد برنامج يقوم بالعمل الأتي
1. من حاسب Admin ارسال برنامج Rmi للحواسيب المتصلة لاحضار معلومات معلومات عن الذكره
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class RemoteExample extends UnicastRemoteObject
implements RemoteExampleInterface {
int value;
String name;
synchronized int square(int i, String s1, String s2) throws RemoteException {
value = i;
name = s1 + s2;
System.out.println("i = " + i);
return i*i;
}
}
marshall__square(class__RemoteExample *this, int i, class__String *s1, class__String *s2) {
MarshallStruct *m = allocMarshallStruct();
ObjectTable = createObjectTable();
writeHeader(m->outBuffer, this, OPCODE_CALL, CREATE_THREAD);
writeInt(m->outBuffer, i);
writeObject(m->outBuffer, s1, ObjectTable);
writeObject(m->outBuffer, s2, ObjectTable);
// Request message is created, now write it to the network.
flushMessage(m->outBuffer);
fillMessage(m->inBuffer); // Receive reply.
opcode = readInt(m->inBuffer);
if (opcode == OPCODE_EXCEPTION) {
class__Exception *exception = readObject(m->inBuffer, ObjectTable);
freeMarshallStruct(m);
THROW_EXCEPTION(exception);
} else {
result = readInt(m->inBuffer);
freeMarshallStruct(m);
RETURN(result);
}
}
unmarshall__square(class__RemoteExample *this, MarshallStruct *m) {
ObjectTable = createObjectTable();
int i = readInt(m->inBuffer);
class__String *s1 = readObject(m->inBuffer, ObjectTable);
class__String *s2 = readObject(m->inBuffer, ObjectTable);
result = CALL_JAVA_FUNCTION(square, this, i, s1, s2, &exception);
if (exception) {
writeInt(m->outBuffer, OPCODE_EXCEPTION);
writeObject(m->outBuffer, exception, ObjectTable);
} else {
writeInt(m->outBuffer, OPCODE_RESULT_CALL);
writeInt(m->outBuffer, result);
}
// Reply message is created, now write it to the network.
flushMessage(m->outBuffer);
}