Hi. Everyone.
Nice see you here.
I am scott from gaucho.net, a .NET programmer primarly.
I am working on gaucho.net’s web chat function. I build it using openfire as jabber server. Using monitoring plugin to track members chat history. This week, my customer stongly wants the “block user” and “off the record” feature. (Check my attachment). After check openfire and jabber client library, I realize there is not such feature in openfire. And because “block user” and “off the record” are one-to-one feature, which means monitoring plugin doesn’t support it too.
After few thought, I decided to add it to monitoring plugin. In my view, monitoring plugin is the correct place to start. Because I have to control chat history track process.
So my first JAVA program started from here.
Through 3 days hard working for JAVA plugin part and our jabber proxy and our web chat client, I believe the “block user” and “off the record” are correctly implement and it works. JAVA looks nearly same to C# and easy to use. Just the building process (ant plugins) takes a real long time which makes me sleepy each time it build.
Build->compling->packing. Stop openfire->replace plugin-> start openfire->test->checking log.
Sign~~~
When can Java has a real IDE like visual studio
Back to track, I pasted my code and ms_sql.sql here so if anyone need same feature he can use this. I am an opensource fans and respect people’s work. Openfire devs are awesome! All of you are awesome.
Here is steps to use my monitoring plugin:
- create ofBanUser and ofOffRecordTable
CREATE TABLE [dbo].[ofBanUser](
[id] [int] IDENTITY(1,1) NOT NULL,
[jid] nvarchar NOT NULL,
[peerJid] nvarchar NOT NULL,
CONSTRAINT [PK_ofBanUser] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
CREATE NONCLUSTERED INDEX IX_ofBanUser_ban ON dbo.ofBanUser
(
jid,
peerJid
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY];
CREATE TABLE [dbo].[ofOffRecord](
[id] [int] IDENTITY(1,1) NOT NULL,
[jid] nvarchar NOT NULL,
[peerJid] nvarchar NOT NULL,
CONSTRAINT [PK_ofOffRecord] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
CREATE NONCLUSTERED INDEX IX_ofOffRecord_offrecord ON dbo.ofOffRecord
(
jid,
peerJid
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY];
- Replace following files with mine, then use ‘ant plugins’ to build monitoring plugin.
Archive/ConversationManager.java
Archive/ArchiveInterceptor.java
-
deploy your new plugin to openfire plugin folder.
-
During chat, when you want to block/off record
Create a message without body, if body, we will treat this message as ‘event’, not ‘user message’
Message msg = new agsXMPP.protocol.client.Message();
msg.Type = MessageType.chat;
msg.To = new Jid(toUser);
msg.Attributes.Add(“action”, action);
XmppCon.Send(msg);
Add a attribute “action”,
“action” support 4 actions:
-
“block” - this will block all messages between you 2.
-
“unblock” - this will remove your block. if peer still block you, you 2 can’t talk either.
-
“off_record” - this will turn off the monitoring’s message archive feature for you 2. All your chat will not be SAVED.
-
“on_record” - this will reenable the message archive feature. All your chat will be SAVED.
BTW, don’t forget to turn on the one-to-one message chat in monitoring’s setting page. I didn’t touch that.
That’s all.
Welcome any comment, if you need few help, see may I could give a hand.
Thanks all for reading.
Scott Zhang