IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası
  sohbet

Yeni Konu aç Cevapla
 
LinkBack Seçenekler Stil
Alt 02 Şubat 2012, 18:18   #1
Çevrimdışı
~ IRCTR.Org ~
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (1)
IF Ticaret Yüzdesi:(%)
Dış Yöntemleri API






ConferenceRoom, Enterprise Edition, sohbet sunucusuna doğrudan arabirim için özel kod sağlamak için bir arayüz destekler. UNIX platformlar için özel kod, paylaşılan bir nesne (bu nedenle) dosyası şeklinde verilmelidir. WIN32 platformlar için özel kod bir DLL dosyası şeklinde verilmelidir.

Aşağıdaki uyarılar göz önünde tutulmalıdır: özel kod Bugs sohbet sunucusuna istikrarsızlaştırmak ya da çökmesine neden olabilir. ConferenceRoom okuyuculu ve kod parçacığı güvenli olmalıdır. Kodu yeniden katılımcıya değilse, muteksler yada kritik bölümleri ile korumak gerekir.

ConferenceRoom elde tutulan olarak mümkün olan en az sayıda kilitler ile kodunuzu arayacak. Normalde ConferenceRoom kod çalışırken, en fazla tek bir kullanıcı bağlantı kilidi olacak. Bu, performansı artırır, ancak bazı yan etkileri vardır.

Bir kullanıcı bir kanala katılmak için çalışır ve AuthenticeJoin bağladım var varsayalım. Kodunuzu çalışırken, sadece tek bir kullanıcı bağlantı kilitli olduğunu, bir operatör kodu çalışırken o kullanıcı öldürebilir. Bu durumda, kullanıcı kanala izin vermek doğru bir dönüş kodu bile, kullanıcı o artık sunucuda beri kanala kadar rüzgar olmayacak.

UNIX platformlarında, C veya C + + kod oluşturmak için. WIN32 platformlarda, size bir DLL oluşturmak mümkün kılan herhangi bir dil kullanmak, ancak Visual C + + 5.0 veya üstü tavsiye edilir.

Ayrı ayrı kesmek isteyen her işlevi kanca ConferenceRoom kılınmalıdır. Eğer birden fazla işlevi aynı nesne dosyası kanca, sadece yüklenen / bir kez initalized.

Callbacks kodunuzu arayabilirsiniz CR işlevleri. Çağrılarıyla kodunuzda CR arama işlevleri. Çağrılarıyla CR yapılandırılmış olması gerekir. Herhangi bir özel yapılandırmaya gerek kalmadan istediğiniz geriçağırımları kullanabilirsiniz.

Komutu (yönetici ayrıcalıklarına sahip bir chat istemcisi) ile çizgisi yapılandırın:
/AS function <CallOutName> del

Dosya bir dizin altında lib denilen ana ConferenceRoom dizin (bin dizini altında olan biri olmalı bir işlevi zaten bağımlısı olduğunu (hatta başarısız olduğunda), ilk olarak kancasını gerektiğini unutmayın.

/AS function <CallOutName> add <FileName>.<extension>

Aşağıdaki geriçağırımları henüz tanımlanmıştır:

DoDebug: Bu komut ConferenceRoom hata ayıklama günlüğü bir girdi ekler. Bu normalde ConferenceRoom kendisi hata ayıklamaya çalışıyorsanız dışında kullanışlı değildir. Normalde kendi dosya hata ayıklama bilgilerini yazmak gerekir.

LockModule: Artışlar boşaltma ConferenceRoom engelleyen bir modül kullanım sayısı,. , Örneğin, kendi iş parçacığı oluşturmak, bir konuya çalışırken modül boşaltmak için ConferenceRoom istemiyorum çünkü bu işlev çağrısı - Bu felaket olurdu.

UnlockModule: azaltır modülü kullanım sayısı.

GetTime: Bu ConferenceRoom sunucu zaman alır. Bu sistem zaman çeşitli nedenlerle farklı olabilir. Bu süre eksiltme asla garanti ve herhangi bir zaman değerleri üzerinden atlamak için garanti edilir.

DOAS: Bu geriçağırım parçası olarak kapalı bırakın içeri bir yönetici yazdığınız gibi bir AS komutu çalıştırır.

Aşağıdaki çağrılarıyla henüz tanımlanmıştır:

AuthenticateUser: Bu çizgisi, sunucu ya da güncel bir yerel kullanıcı değişiklikler takma her zaman yeni bir kullanıcı işaretleri denir olacak. / Connect değişiklik izin verilen veya izin verilmeyen ve kullanıcıya gönderilen bir mesaj olabilir.

AuthenticateJoin: Bu çizgisi, yerel bir kullanıcının bir kanala katılmak için çalışır her zaman çağrılır. Katılmak ya da izin verilmeyen izin olabilir ve kullanıcı bir mesaj gönderilebilir.

DisconnectUser: Bu fonksiyon, önceden var olan bir kullanıcı aynı kullanıcı adı ile bağlantısını kesmek için imzalar bir kullanıcı sağlar.

Komut: Bu çizgisi, bir istemci 'CMD' komutu kullanan her zaman olarak adlandırılır. Bu günlüğü ya da başka amaçlar için özel kod sohbet müşterilerinden gelen bilgi aktarmak için bir yol sağlamak için kullanılır. 780 sayısal şeklinde bir mesaj iade edilebilir. Bu uzaktan kontrol sunucusu yapılandırma değişiklikleri sağlamak için DOAS geri çağırma ile birlikte kullanılabilir. Bu aynı zamanda, özel komutlar uygulanması veya günlüğe bir yolu olarak kullanılabilir.

CreateChannel: Bu çizgisi yerel bir istemci (boş bir kanala) yeni bir kanal oluşturmak için çalışır her zaman çağrılır. Oluşturulması, izin veya reddedilebilir.

UserParted: Bu bir günlük işlevi, yerel bir kullanıcı bir kanal (herhangi bir yolla) terk ettiğini rapor etmek adı verilecek.






Kod:   Kodu kopyalamak için üzerine çift tıklayın!
#include <stddef.h> /* for size_t */ #include <string.h> /* for strcpy/strcasecmp */ #include <stdio.h> /* for sprintf */ /* Example Native Code By: David J. Schwartz <davids@[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...].com> Copyright (C) 1999-2000, WebMaster, Incorporated $Id: lib.cpp,v 1.11 2001/08/08 18:37:36 cvs Exp $ On UNIX, compile with (may be different on your machine) c++ test.cpp -c -DUNIX -o test.o -fPIC (Some platforms may not need '-fPIC' or may want '-fpic') Linux: ld -shared test.o -o test.so Solaris: ld -G test.o -o test.so (You can use a C or C++ compiler) Then put in a 'lib' directory under the CR directory. Then tell CR: /as function <FunctionName> add <FileName>.<so|dll> On NT, compile/link into a DLL using whatever means you like. All remotely accessible functions should have C linkage. */ #ifdef WIN32 #define strcasecmp stricmp #if defined(__cplusplus) #define EXPORT extern "C" __declspec(dllexport) #define XPROTO __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #define XPROTO __declspec(dllexport) #endif #endif #ifdef UNIX #define EXPORT #define XPROTO #endif #if defined(__cplusplus) extern "C" { #endif XPROTO void RegisterCallbackHandler(void *[]); XPROTO int AuthenticateUser(const char *, const char *, const char *, const char *, char *, size_t); XPROTO int DisconnectUser(const char *, const char *, const char *, char *, size_t); XPROTO int Command(const char *, const char *, const char *, const char *, const char *, const char *, char *, size_t); XPROTO int AuthenticateJoin(unsigned, const char *, const char *, const char *, const char *, const char *, char *, size_t); XPROTO int CreateChannel(const char *, const char *, const char *, const char *, const char *, const char *, char *, size_t); XPROTO int UserDisconnected(const char *, const char *, const char *, const char *, const char *, int); XPROTO int UserParted(const char *, const char *, const char *, const char *, const char *, int); void (*CallBackRoutine)(int, void *[]); #if defined(__cplusplus) }; #endif /* CR gives us a module handle that we use to uniquely identify ourself. It's needed so that CR knows where callbacks are coming from. */ void *Handle; /* DoDebug is an example of a routine that calls back into CR. All callbacks have numeric indexes. The callback handler is thread safe as well, so you can start your own threads and make calls back into CR willy-nilly. However, you will have to register each thread with CR and clean it up when done. (So CR can adjust the 'usage count' of the library and not unload it while it's got a thread in its code!) Every callback function takes an array of void pointers. The first pointer on input must always be the module handle. */ void DoDebug(const char *msg) { /* Do not modify this function */ void *a[2]; a[0]=Handle; a[1]=(void *) msg; CallBackRoutine(-4, a); } /* When you create a thread or otherwise make your module 'busy', you must call 'LockModule' to warn CR not to unload the module. When you are done, you must call 'UnlockModule'. Each call to 'LockModule' increments the usage count of this module by one. Misuse of these functions WILL cause CR to crash. */ void LockModule(void) { /* Do not modify this function */ void *a[1]; a[0]=Handle; CallBackRoutine(-9, a); } void UnlockModule(void) { /* Do not modify this function */ void *a[1]; a[0]=Handle; CallBackRoutine(-10, a); } /* This function gets CR's internal time. CR's internal time may not match the system time. */ time_t GetTime(void) { /* Do not modify this function */ void *a[2]; a[0]=Handle; CallBackRoutine(-7, a); return (time_t) a[1]; } /* DoAS is a callback routine that allows you to execute an 'AS' command. The return value indicates the success or failure of the command. If the 'reply' buffer is large enough, CR's response to the command will be copied into it. */ int DoAS(const char *cmd, char *reply, int buf_siz) { /* Do not modify this function */ void *a[4]; a[0]=Handle; a[1]=(void *) cmd; CallBackRoutine(1, a); char *r=(char *) a[3]; if(strlen(r)<buf_siz) strcpy(reply, r); free(a[3]); return (int) a[2]; } /* CR calls RegisterCallbackHandler when it loads a library to tell the library its library handle and give it a pointer to CR's callback handler. */ EXPORT void RegisterCallbackHandler(void *a[]) { /* Save the information we've been given */ CallBackRoutine=(void (*)(int, void *[])) a[0]; Handle=a[1]; /* Put any initialization code you might need here You are guaranteed that this function will be called once and only once upon module loading */ /* The following line just lets us know that we've been loaded */ /* It will appear in CR's debug log */ DoDebug("We've been hooked"); } /* This is a silly version of the AuthenticateUser function just to test. It disallows all nick changes except for case changes and refuses to permit nicknames with 'reject' in them. CR will call the AuthenticateUser hook any time a local user signs on to the server or changes nicknames. */ EXPORT int AuthenticateUser(const char *oldnick, const char *newnick, const char *username, const char *password, char *replybuf, size_t buflen) { DoDebug("AuthenticateUser has been called"); if(oldnick==NULL) { /* oldnick is NULL if this is a user signing on */ DoDebug("It's a new nickname"); if(strstr(newnick,"reject")!=NULL) { DoDebug("Nickname contains 'reject', rejecting"); if(buflen>40) strcpy(replybuf,"Don't use 'reject' in a nickname"); return 1; } DoDebug("Allowing"); return 0; /* allow */ } /* if newnick is not NULL, this is a nick change */ if(strncmp(oldnick,"Guest",5)==0) { DoDebug("Allowing change from guest"); return 0; /* allow change from guest */ } if(strcasecmp(oldnick,newnick)!=0) { DoDebug("Not allowing nick change"); if(buflen>43) strcpy(replybuf,"I hate nick changes"); return 1; /* deny */ } DoDebug("Changes only case, allowing"); return 0; /* allow */ } /* The Command hook is used to pass information from a chat client to customized code. It also allows the customized code to send a reply back to the client. It can be used to add features to CR. The example code belows just tells the user what he sent. */ EXPORT int Command(const char *nick, const char *user, const char *host, const char *realname, const char *server, const char *command, char *replybuf, size_t buflen) { DoDebug("Command has been called"); char buf[512]; sprintf(buf,"n=%s u=%s h=%s rn=%s srv=%s cmd=%s", nick,user,host,realname,server,command); strcpy(replybuf, buf); /* Squirt back our parameters */ return 1; /* 1 = send message */ } /* The AuthenticateJoin function is used to permit or refuse an attempt to join a channel. The 'type' field consists of the bitwise OR of these flags: 1 - SAJOIN 2 - User is +o 4 - User is +h 8 - Channel was created by the join And the permitted return values are the bitwise OR of these flags: 1 - Allow join 2 - Set +u in channel 4 - Set +v in channel 8 - Set +o in channel Currently, the reply message is sent only if the join is refused. The 'password' is the most recent password sent using the 'PASS' command. The 'join_key' is the last parameter to the JOIN command and is used to get into keyed channels. */ EXPORT int AuthenticateJoin(unsigned type, const char *nickname, const char *username, const char *password, const char *channel, const char *join_key, char *replybuf, size_t buflen) { if(type & 8) return 8; /* If creating channel, op */ return 1; } /* The DisconnectUser function is called when a user signs on with a nickname that is already is use. If you can establish that this newly connecting user has authoritative rights to the nickname, you can return a '1', and the old user will be killed and the new user allowed to use the nickname. */ EXPORT int DisconnectUser(cosnt char *nick, const char *user, const char *pass, char *replybuf, size_t buflen) { return 0; /* 1 = disconnect existing user */ } /* This function will be called any time a user attempts to create a channel (by joining an empty one). Returning a zero permits the channel to be created. If you don't put a message in the replybuf, a NOSUCHCHANNEL error numeric will be sent. */ EXPORT int CreateChannel(const char *channel, const char *nickname, const char *username, const char *hostname, const char *password, const char *join_key, char *replybuf, size_t buflen) { return 0; } /* This function will be called any time a user disconnects. It is intended to be used for logging. The return value is ignored. The 'code' means: 0 = normal close, 1 = timeout (for HTML/Envoy clients) 2 = deconfigured (for bots), 3 = lost in split 4 = disconnect requested for unspecified reason 5 = quit command, 6 = z-lined while connected 7 = mkill command, 8 = kill command 9 = DisconnectUser hook requested disconnect 10 = K-lined, 11 = collision, 12 = ping timeout 13 = unknown (code last track of object) 14 = type mismatch (expected server, outbound connection) 15 = banned, 16 = no privileges (no client class) 17 = client class full 19 = client class doesn't allow clones 20 = AuthenticateUser hook refused connection 21 = user squit himself, 22 = excess flood 99 = sendq not draining, 100 = normal close >100 = system error, subtract 100 for code */ EXPORT int UserDisconnected(const char *nickname, const char *username, const char *hostname, const char *realname, const char *reason, int code) { return 0; } /* This function will be called any time a user parts a channel. It is intended to be used for logging. The return value is ignored. The 'code' means: 0=PARTed, 1=QUIT/error, 2=KICKed, 3=KILLed */ EXPORT int UserParted(const char *nickname, const char *username, const char *hostname, const char *channel, const char *reason, int code) { return 0; }


 
Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
sohbet odaları sohbet odaları Benimmekan Mobil Sohbet
Cevapla

Etiketler
api, dış, yöntemleri


Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir)
 
Seçenekler
Stil

Yetkileriniz
Konu Acma Yetkiniz Yok
Cevap Yazma Yetkiniz Yok
Eklenti Yükleme Yetkiniz Yok
Mesajınızı Değiştirme Yetkiniz Yok

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-Kodu Kapalı
Trackbacks are Kapalı
Pingbacks are Açık
Refbacks are Açık


Benzer Konular
Konu Konuyu Başlatan Forum Cevaplar Son Mesaj
Dış Yöntemleri API DaDaS CR Makaleler 0 02 Şubat 2012 18:12
Saç Ekleme Yöntemleri efLatun Güzellik, Sağlık ve Bakım Önerileri 0 28 Ocak 2012 21:36