
Fısıltıda "Yazıyor..." seçeneğini sunucunuza kurmak için;
1.Adım
Dosyayı indir
2.Adım
Client projesine ise UserInterface-sağ tık-Add Item-Exist Item şeklinde
PythonWhisper.cpp ekle
C++:
#include "StdAfx.h"
#ifdef ENABLE_WHISPER_RENEWAL
#include "PythonWhisper.h"
#include "PythonNetworkStream.h"
PyObject * AddName(PyObject * poSelf, PyObject * poArgs)
{
char* Name;
if (!PyTuple_GetString(poArgs, 0, &Name))
return Py_BadArgument();
CPythonNetworkStream::Instance().SendWhisperPacket(Name, "|?whisper_renewal>|");
CPythonWhisper::Instance().AddName(Name, CPythonWhisper::ME);
return Py_BuildNone();
}
PyObject * DeleteName(PyObject * poSelf, PyObject * poArgs)
{
char* Name;
if (!PyTuple_GetString(poArgs, 0, &Name))
return Py_BadArgument();
CPythonNetworkStream::Instance().SendWhisperPacket(Name, "|?whisper_renewal<|");
CPythonWhisper::Instance().DeleteName(Name, CPythonWhisper::ME);
return Py_BuildNone();
}
PyObject * CheckName(PyObject * poSelf, PyObject * poArgs)
{
char* Name;
if (!PyTuple_GetString(poArgs, 0, &Name))
return Py_BadArgument();
return Py_BuildValue("i", CPythonWhisper::Instance().CheckName(Name, CPythonWhisper::TARGET));
}
PyObject * IsSended(PyObject * poSelf, PyObject * poArgs)
{
char* Name;
if (!PyTuple_GetString(poArgs, 0, &Name))
return Py_BadArgument();
return Py_BuildValue("i", CPythonWhisper::Instance().CheckName(Name, CPythonWhisper::ME));
}
void initWhisper()
{
static PyMethodDef functions[] = {
{"Add", AddName, METH_VARARGS}, // to target
{"Remove", DeleteName, METH_VARARGS}, // to target
{"CheckName", CheckName, METH_VARARGS}, // my list
{"IsSended", IsSended, METH_VARARGS},
{NULL, NULL, NULL},
};
PyObject* pModule = Py_InitModule("whisper", functions);
}
#endif
PythonWhisper.h ekle
C++:
#pragma once
#ifdef ENABLE_WHISPER_RENEWAL
class CPythonWhisper : public CSingleton<CPythonWhisper>
{
public:
CPythonWhisper() { Clear(); };
virtual ~CPythonWhisper() { Clear(); };
enum { TARGET, ME };
void Clear() {for (int i = TARGET; i <= ME; i++) b_writing[i].clear();};
void AddName(std::string name, BYTE i) {if (std::find(b_writing[i].begin(), b_writing[i].end(), name) == b_writing[i].end()) b_writing[i].emplace_back(name);};
void DeleteName(std::string name, BYTE i) {if (std::find(b_writing[i].begin(), b_writing[i].end(), name) != b_writing[i].end()) b_writing[i].remove(name);};
bool CheckName(std::string name, BYTE i) {return(std::find(b_writing[i].begin(), b_writing[i].end(), name) != b_writing[i].end());};
protected:
std::list<std::string> b_writing[ME+1];
};
#endif